From: Bjørn Erik Pedersen Date: Tue, 7 Apr 2026 19:44:38 +0000 (+0200) Subject: parser/pageparser: Add a parser fuzz test X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8f94d65cac169688ce1fa085af00f2cd92a2086b;p=brevno-suite%2Fhugo parser/pageparser: Add a parser fuzz test Ran it for 40 minutes on my MacBook Pro, and it found no issues. --- diff --git a/parser/pageparser/pageparser_test.go b/parser/pageparser/pageparser_test.go index de7d2e140..561ad7ea2 100644 --- a/parser/pageparser/pageparser_test.go +++ b/parser/pageparser/pageparser_test.go @@ -22,6 +22,33 @@ import ( "github.com/gohugoio/hugo/parser/metadecoders" ) +func FuzzParse(f *testing.F) { + samples := []string{ + `{{< foo >}}`, + `{{% foo %}}`, + `{{< foo >}} {{< bar >}}`, + `--- +title: "Front Matters" +--- + +This is some summary. This is some summary. This is some summary. This is some summary. + + + + Foo bars. + + `, + } + for _, s := range samples { + f.Add([]byte(s)) + } + + f.Fuzz(func(t *testing.T, b []byte) { + cfg := Config{} + _, _ = parseBytes(b, cfg, lexIntroSection) + }) +} + func BenchmarkParse(b *testing.B) { start := `