Compare commits

..

2 Commits

Author SHA1 Message Date
6a513bbcac refactor: simplify return in ValidateFuzzInputStrict() 2025-11-14 07:16:54 +01:00
69e61c5811 feat: use SplitSeq 2025-11-14 07:16:20 +01:00
2 changed files with 5 additions and 10 deletions

View File

@@ -123,8 +123,8 @@ type HTTPFuzzTestCase struct {
} }
func (h *FuzzTestHelper) validateHTTPRequest(t *testing.T, req *http.Request) { func (h *FuzzTestHelper) validateHTTPRequest(t *testing.T, req *http.Request) {
pathParts := strings.Split(req.URL.Path, "/") pathParts := strings.SplitSeq(req.URL.Path, "/")
for _, part := range pathParts { for part := range pathParts {
if !utf8.ValidString(part) { if !utf8.ValidString(part) {
t.Fatal("Path contains invalid UTF-8") t.Fatal("Path contains invalid UTF-8")
} }

View File

@@ -40,12 +40,7 @@ func (f *FuzzInputValidator) ValidateFuzzInputStrict(data []byte) bool {
} }
input := string(data) input := string(data)
return len(strings.TrimSpace(input)) != 0
if len(strings.TrimSpace(input)) == 0 {
return false
}
return true
} }
func ValidateUTF8String(s string) { func ValidateUTF8String(s string) {
@@ -210,8 +205,8 @@ func (r *FuzzHTTPRequest) CreateTestRequest(method, url string, body []byte, hea
} }
func (r *FuzzHTTPRequest) ValidateHTTPRequest(req *http.Request) { func (r *FuzzHTTPRequest) ValidateHTTPRequest(req *http.Request) {
pathParts := strings.Split(req.URL.Path, "/") pathParts := strings.SplitSeq(req.URL.Path, "/")
for _, part := range pathParts { for part := range pathParts {
ValidateUTF8String(part) ValidateUTF8String(part)
} }