Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f94d65

Browse files
committed
parser/pageparser: Add a parser fuzz test
Ran it for 40 minutes on my MacBook Pro, and it found no issues.
1 parent d6bc816 commit 8f94d65

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

parser/pageparser/pageparser_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ import (
2222
"github.com/gohugoio/hugo/parser/metadecoders"
2323
)
2424

25+
func FuzzParse(f *testing.F) {
26+
samples := []string{
27+
`{{< foo >}}`,
28+
`{{% foo %}}`,
29+
`{{< foo >}} {{< bar >}}`,
30+
`---
31+
title: "Front Matters"
32+
---
33+
34+
This is some summary. This is some summary. This is some summary. This is some summary.
35+
36+
<!--more-->
37+
38+
Foo bars.
39+
40+
`,
41+
}
42+
for _, s := range samples {
43+
f.Add([]byte(s))
44+
}
45+
46+
f.Fuzz(func(t *testing.T, b []byte) {
47+
cfg := Config{}
48+
_, _ = parseBytes(b, cfg, lexIntroSection)
49+
})
50+
}
51+
2552
func BenchmarkParse(b *testing.B) {
2653
start := `
2754

0 commit comments

Comments
 (0)