summaryrefslogtreecommitdiffstats
path: root/services/gitdiff/gitdiff_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-08-22 16:07:37 +0100
committerGitHub <noreply@github.com>2020-08-22 16:07:37 +0100
commit7a8a05cc44a7ddf39ddea679434acacc8f47dfc1 (patch)
tree74d43f1cf40ea39f243e81034db262816d45f400 /services/gitdiff/gitdiff_test.go
parentfcabbae1686b82cb495d8d430279b745a707f377 (diff)
downloadgitea-7a8a05cc44a7ddf39ddea679434acacc8f47dfc1.tar.gz
gitea-7a8a05cc44a7ddf39ddea679434acacc8f47dfc1.zip
Fix diff path unquoting (#12554)
* 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 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/gitdiff/gitdiff_test.go')
-rw-r--r--services/gitdiff/gitdiff_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go
index 597c9d394e..9826ece2dc 100644
--- a/services/gitdiff/gitdiff_test.go
+++ b/services/gitdiff/gitdiff_test.go
@@ -112,6 +112,23 @@ func TestParsePatch(t *testing.T) {
}
println(result)
+ var diff2a = `diff --git "a/A \\ B" b/A/B
+--- "a/A \\ B"
++++ b/A/B
+@@ -1,3 +1,6 @@
+ # gitea-github-migrator
++
++ Build Status
+- Latest Release
+ Docker Pulls
++ cut off
++ cut off`
+ result, err = ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(diff2a))
+ if err != nil {
+ t.Errorf("ParsePatch failed: %s", err)
+ }
+ println(result)
+
var diff3 = `diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md