You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example with the url /api/v3/repos/<owner>/<repo>/contents/subfolder/test.md the linked code results in the following execution flow:
paths will be ['subfolder', 'test.md']
path will be subfolder (all elements except last joined with /)
getFileInfo is called with subfolder
this tries to trim the filename from the given path, resulting in . directory and subfolder filename
since subfolder is an existing folder in the root, the code is interpreted as trying to "update" a "file" with subfolder filename to the root directory
This is a consequence of a previous refactor which introduced the getFileInfo call #2802
The solution itself would be to directly pass the result of multiParams("splat") to the getFileInfo so it can appropriately determine the directory and filename.
val fullPath = multiParams("splat").head;
val paths = fullPath.split("/")
val path = paths.take(paths.size - 1).toList.mkString("/")
// ...
val fileInfo = getFileInfo(git, commit, fullPath, false)
The text was updated successfully, but these errors were encountered:
Issue
Impacted version: 4.39.0 (current latest)
Deployment mode: Self-hosted, API request
Problem description:
With the file content (upload) API, the given path is inproperly trimmed (twice), see:
gitbucket/src/main/scala/gitbucket/core/controller/api/ApiRepositoryContentsControllerBase.scala
Line 148 in ca25e7f
For example with the url
/api/v3/repos/<owner>/<repo>/contents/subfolder/test.md
the linked code results in the following execution flow:paths
will be['subfolder', 'test.md']
path
will besubfolder
(all elements except last joined with/
)getFileInfo
is called withsubfolder
.
directory andsubfolder
filenamesubfolder
is an existing folder in the root, the code is interpreted as trying to "update" a "file" withsubfolder
filename to the root directoryThis is a consequence of a previous refactor which introduced the
getFileInfo
call #2802The solution itself would be to directly pass the result of
multiParams("splat")
to thegetFileInfo
so it can appropriately determine the directory and filename.The text was updated successfully, but these errors were encountered: