Make ParsePatch more robust (#17573)
This commit is contained in:
parent
69b61d4373
commit
30515f2df3
2 changed files with 30 additions and 1 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue