* Fix diff path unquoting services/gitdiff/gitdiff.go whereby there it assumed that the path would always be quoted on both sides This PR simplifies the code here and uses fmt.Fscanf to parse the strings as necessary. Fix #12546 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add testcase as per @mrsdizzie
Showing the changes to services/gitdiff/gitdiff_test.go (1 of 2 files). Show all
Unified · Split
| @@ -112,6 +112,23 @@ func TestParsePatch(t *testing.T) { · 111 unmodified lines | |||
| 112 | } | 112 | } |
| 113 | println(result) | 113 | println(result) |
| 114 | 114 | ||
| 115 | var diff2a = `diff --git "a/A \\ B" b/A/B | ||
| 116 | --- "a/A \\ B" | ||
| 117 | +++ b/A/B | ||
| 118 | @@ -1,3 +1,6 @@ | ||
| 119 | # gitea-github-migrator | ||
| 120 | + | ||
| 121 | + Build Status | ||
| 122 | - Latest Release | ||
| 123 | Docker Pulls | ||
| 124 | + cut off | ||
| 125 | + cut off` | ||
| 126 | result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a)) | ||
| 127 | if err != nil { | ||
| 128 | t.Errorf("ParsePatch failed: %s", err) | ||
| 129 | } | ||
| 130 | println(result) | ||
| 131 | |||
| 115 | var diff3 = `diff --git a/README.md b/README.md | 132 | var diff3 = `diff --git a/README.md b/README.md |
| 116 | --- a/README.md | 133 | --- a/README.md |
| 117 | +++ b/README.md | 134 | +++ b/README.md |