mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-27 11:01:48 +01:00
fix(gitdiff): unquote C-quoted paths from git diff-tree --raw (#39781)
`parseGitDiffTreeLine` (`services/gitdiff/git_diff_tree.go`) read `BasePath`/`HeadPath` straight from `git diff-tree --raw` output without undoing git's C-quoting, unlike its sibling `parseLsTreeLine` (`modules/git/parse.go`), which already does this with `strconv.Unquote`. This fix applies the same unquoting to both paths in the diff-tree parser. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
1 parent
76f8dc38e7
commit
c6069f8d9f
3 files changed
+40
-18
No files matched your search
@@ -324,6 +324,22 @@ func TestParseGitDiffTree(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// make sure our code can unquote paths no matter core.quotePath is true or false: quoted chars are like "\t" or "\{oct}"
|
||||
Name: "file modified with a C-quoted path",
|
||||
GitOutput: ":100644 100644 b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0 04fea06420ca60892f73becee3614f6d023a4b7f M\t" + `"\346\227\245\346\234\254\350\252\236\ttest.txt"`,
|
||||
Expected: []*DiffTreeRecord{
|
||||
{
|
||||
Status: "modified",
|
||||
HeadPath: "日本語\ttest.txt",
|
||||
BasePath: "日本語\ttest.txt",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
BaseMode: git.EntryModeBlob,
|
||||
HeadBlobID: "04fea06420ca60892f73becee3614f6d023a4b7f",
|
||||
BaseBlobID: "b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "no changes",
|
||||
GitOutput: ``,
|
||||
|
||||
Reference in new issue
Block a user