1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

test(sanitizer): add unit test for 0x0 pixel tracker

This commit is contained in:
Frédéric Guillot 2025-06-17 17:36:09 -07:00
parent cdb57b3843
commit 27015a5e34

View file

@ -709,7 +709,7 @@ func TestImageSrcWithTrackers(t *testing.T) {
}
}
func TestPixelTracker(t *testing.T) {
func Test1x1PixelTracker(t *testing.T) {
input := `<p><img src="https://tracker1.example.org/" height="1" width="1"> and <img src="https://tracker2.example.org/" height="1" width="1"/></p>`
expected := `<p> and </p>`
output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
@ -719,6 +719,16 @@ func TestPixelTracker(t *testing.T) {
}
}
func Test0x0PixelTracker(t *testing.T) {
input := `<p><img src="https://tracker1.example.org/" height="0" width="0"> and <img src="https://tracker2.example.org/" height="0" width="0"/></p>`
expected := `<p> and </p>`
output := SanitizeHTMLWithDefaultOptions("http://example.org/", input)
if expected != output {
t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
}
}
func TestXmlEntities(t *testing.T) {
input := `<pre>echo "test" &gt; /etc/hosts</pre>`
expected := `<pre>echo &#34;test&#34; &gt; /etc/hosts</pre>`