From 4a943b722de86abe13dbfb0fa6e790a04226f065 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 26 Feb 2024 13:44:42 +0100 Subject: [PATCH] Add a couple of fuzzers --- internal/reader/date/parser_test.go | 8 ++++ internal/reader/parser/parser_test.go | 56 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/internal/reader/date/parser_test.go b/internal/reader/date/parser_test.go index 6b7b2a89..b3ae2214 100644 --- a/internal/reader/date/parser_test.go +++ b/internal/reader/date/parser_test.go @@ -7,6 +7,14 @@ import ( "testing" ) +func FuzzParse(f *testing.F) { + f.Add("2017-12-22T22:09:49+00:00") + f.Add("Fri, 31 Mar 2023 20:19:00 America/Los_Angeles") + f.Fuzz(func(t *testing.T, date string) { + Parse(date) + }) +} + func TestParseEmptyDate(t *testing.T) { if _, err := Parse(" "); err == nil { t.Fatalf(`Empty dates should return an error`) diff --git a/internal/reader/parser/parser_test.go b/internal/reader/parser/parser_test.go index 07972474..abaf1094 100644 --- a/internal/reader/parser/parser_test.go +++ b/internal/reader/parser/parser_test.go @@ -8,6 +8,62 @@ import ( "testing" ) +func FuzzParse(f *testing.F) { + f.Add("https://z.org", ` + +Example Feed + + +2003-12-13T18:30:02Z +John Doe +urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 + +a + +urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a +2003-12-13T18:30:02Z +c + +`) + f.Add("https://z.org", ` + + +a +http://z.org + +a +http://z.org +d +Tue, 03 Jun 2003 09:39:21 GMT +l + + +`) + f.Add("https://z.org", ` + + +a +http://z.org/ + + +a +/ +c + +`) + f.Add("http://z.org", `{ +"version": "http://jsonfeed.org/version/1", +"title": "a", +"home_page_url": "http://z.org/", +"feed_url": "http://z.org/a.json", +"items": [ +{"id": "2","content_text": "a","url": "https://z.org/2"}, +{"id": "1","content_html": "