// SPDX-License-Identifier: AGPL-3.0-only package compiler import "testing" func FuzzCompileNeverPanics(f *testing.F) { for _, seed := range []string{ profileSource, "", "", "\n\">x", "\n", "\n\n= v ?>\n", "\xef\xbb\xbf\r\n\r\n
x
", } { f.Add(seed) } f.Fuzz(func(t *testing.T, source string) { _, _ = Compile("fuzz.sando", []byte(source)) }) } func FuzzGoDelimiterNeverPanics(f *testing.F) { for _, seed := range []string{`?>`, `"?>" ?>`, "`?>` ?>", `/* ?> */ ?>`, "// ?>\n?>", `'?' ?>`} { f.Add(seed, uint8(0)) } f.Fuzz(func(t *testing.T, source string, start uint8) { offset := int(start) if offset > len(source) { offset = len(source) } result := findGoDelimiter([]byte(source), offset) if result < -1 || result > len(source) { t.Fatalf("invalid delimiter offset %d for %d bytes", result, len(source)) } }) }