aboutsummaryrefslogtreecommitdiffstats
path: root/services/gitdiff/gitdiff_test.go
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-11-07 18:52:50 +0100
committerGitHub <noreply@github.com>2021-11-07 12:52:50 -0500
commit30515f2df3d75dc81a606725509cda70d8acef98 (patch)
treeada54af56654ea5bbc58202c234b294eb5195f26 /services/gitdiff/gitdiff_test.go
parent69b61d437357235700306f28d22d21acc39bb2b5 (diff)
downloadgitea-30515f2df3d75dc81a606725509cda70d8acef98.tar.gz
gitea-30515f2df3d75dc81a606725509cda70d8acef98.zip
Make ParsePatch more robust (#17573)
Diffstat (limited to 'services/gitdiff/gitdiff_test.go')
-rw-r--r--services/gitdiff/gitdiff_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go
index d69d0c01d8..6decb59b64 100644
--- a/services/gitdiff/gitdiff_test.go
+++ b/services/gitdiff/gitdiff_test.go
@@ -541,3 +541,22 @@ func TestDiffToHTML_14231(t *testing.T) {
assertEqual(t, expected, output)
}
+
+func TestNoCrashes(t *testing.T) {
+ type testcase struct {
+ gitdiff string
+ }
+
+ tests := []testcase{
+ {
+ gitdiff: "diff --git \n--- a\t\n",
+ },
+ {
+ gitdiff: "diff --git \"0\n",
+ },
+ }
+ for _, testcase := range tests {
+ // It shouldn't crash, so don't care about the output.
+ ParsePatch(setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, strings.NewReader(testcase.gitdiff))
+ }
+}