From a313c8a66dddff4e3842bbde5ed236f263fb932b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 17 Jun 2025 17:36:09 -0700 Subject: [PATCH] test(sanitizer): add unit test for 0x0 pixel tracker --- internal/reader/sanitizer/sanitizer_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/reader/sanitizer/sanitizer_test.go b/internal/reader/sanitizer/sanitizer_test.go index 67c88585..76441042 100644 --- a/internal/reader/sanitizer/sanitizer_test.go +++ b/internal/reader/sanitizer/sanitizer_test.go @@ -709,7 +709,7 @@ func TestImageSrcWithTrackers(t *testing.T) { } } -func TestPixelTracker(t *testing.T) { +func Test1x1PixelTracker(t *testing.T) { input := `

and

` expected := `

and

` output := SanitizeHTMLWithDefaultOptions("http://example.org/", input) @@ -719,6 +719,16 @@ func TestPixelTracker(t *testing.T) { } } +func Test0x0PixelTracker(t *testing.T) { + input := `

and

` + expected := `

and

` + output := SanitizeHTMLWithDefaultOptions("http://example.org/", input) + + if expected != output { + t.Errorf(`Wrong output: "%s" != "%s"`, expected, output) + } +} + func TestXmlEntities(t *testing.T) { input := `
echo "test" > /etc/hosts
` expected := `
echo "test" > /etc/hosts
`