gitlab类 ls方法及getCommitsByPath方法的错误
momo
|
class gitlab { // ... public function ls($path, $revision = 'HEAD') foreach($list as $file) { if(!isset($file->type)) continue; $info = new stdClass(); $info->name = $file->name; $info->kind = $file->type == 'blob' ? 'file' : 'dir'; if($file->type == 'blob') { $file = $this->files($file->path, $this->branch); $info->revision = zget($file, 'revision', ''); $info->comment = zget($file, 'comment', ''); $info->account = zget($file, 'committer', ''); $info->date = zget($file, 'date', ''); $info->size = zget($file, 'size', ''); } else { // <<============================= // 在 getCommitsByPath()方法中会使用 urldecode解码, 但是传的参数确没有urlencode编码, // 如此会导致 请求gitlab时, 使用错误的路径. 比如 $file->path = 'xxx+xxx' , 把这个+号直接替换成空格了, // 再比如 $file->path = '%xx%xx' , 这是一个合法的名字, 却接url编码解码了. $commits = $this->getCommitsByPath($file->path);if(empty($commits)) continue; |
禅道-Bee |
谢谢您的反馈,这儿我们反馈给相关同事确认下。
|
丁国栋 |
您好,感谢您的反馈,请问您这是在使用禅道中的哪一个功能遇到问题了?是版本库浏览页面遇到的问题吗?
|
momo
|
随便来个gitlab版本库, 路径上带+号就可以看见问题. 或者类似 %20%2B%2F 这样的名字. |
丁国栋 |
原帖由
momo 于
2021-09-24 08:57:43 发表
随便来个gitlab版本库, 路径上带+号就可以看见问题. 或者类似 %20%2B%2F 这样的名字. 您好,路径中带+号未能复现,如上面2楼帖子图片所示。 “%20%2B%2F”这种的文件已经复现,我们这边做一下改进。感谢您继续反馈。
|
丁国栋 |
原帖由
momo 于
2021-09-24 08:57:43 发表
随便来个gitlab版本库, 路径上带+号就可以看见问题. 或者类似 %20%2B%2F 这样的名字. momo您好,让您久等了,我现在跟您反馈一下我了解到的情况。 禅道会通过GitLab的API 读取Git版本库中文件的信息,其中一个API链接为:https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository , 用于获取文件的信息。 由于GitLab API的原因,GitLab 无法有效识别到file_path中的特殊字符“%”,导致API会提示: {
"error": "file_path should be a valid file path"
}
尽管如此,GitLab自己还是可以识别的。但在RESTfull API中,可能因为HTTP协议的约定可能无法做到有效处理。 因此,我的建议的是不要使用含有“%”这种在URL中有特殊意义的字符。 如果你有更好的建议,欢迎提出。谢谢! |