1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 15:07:20 +00:00

Limit the max line length when parsing git grep output (#30418) (#30427)

Backport #30418 by wxiaoguang

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2024-04-12 12:13:14 +08:00
committed by GitHub
parent 7aa68d6f86
commit 6c228fe5d6
2 changed files with 26 additions and 4 deletions

View File

@ -41,6 +41,16 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "void", GrepOptions{MaxResultLimit: 1, MaxLineLength: 39})
assert.NoError(t, err)
assert.Equal(t, []*GrepResult{
{
Filename: "java-hello/main.java",
LineNumbers: []int{3},
LineCodes: []string{" public static void main(String[] arg"},
},
}, res)
res, err = GrepSearch(context.Background(), repo, "no-such-content", GrepOptions{})
assert.NoError(t, err)
assert.Len(t, res, 0)