From dde64be2724fd4e407315627943dd8dd37e5adf0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 24 Oct 2024 10:15:52 +0300 Subject: fix fuzz test --- Taskfile.yml | 2 +- internal/platforms/linkedin/escapes_test.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 2282f02..5de7842 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,7 +15,7 @@ tasks: cmds: - go build -o gos cmd/gos/main.go dev: - deps: ["test", "fuzz", "vet", "lint"] + deps: ["test", "vet", "lint"] cmds: - go build -race -o gos cmd/gos/main.go test: diff --git a/internal/platforms/linkedin/escapes_test.go b/internal/platforms/linkedin/escapes_test.go index c95ddc9..f93b260 100644 --- a/internal/platforms/linkedin/escapes_test.go +++ b/internal/platforms/linkedin/escapes_test.go @@ -2,6 +2,7 @@ package linkedin import ( "fmt" + "regexp" "slices" "strings" "testing" @@ -69,9 +70,10 @@ func FuzzLinkedInURLExtract(f *testing.F) { f.Add("/path?codsl=fpwfto6j") f.Add("tvdus=fhlhlh1y") f.Add("/foo.txt") + noWhitespace := regexp.MustCompile(`\s+`) f.Fuzz(func(t *testing.T, urlPath string) { - urlPath = strings.TrimSpace(urlPath) + urlPath = noWhitespace.ReplaceAllString(strings.TrimSpace(urlPath), "%20") baseURLs := []string{"https://foo.zone", "http://foo.zone", "ftp://foo.zone"} for _, baseURL := range baseURLs { fullURL := fmt.Sprintf("%s%s", baseURL, urlPath) -- cgit v1.2.3