Procházet zdrojové kódy

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

Frédéric Guillot před 10 měsíci
rodič
revize
27015a5e34
1 změnil soubory, kde provedl 11 přidání a 1 odebrání
  1. 11 1
      internal/reader/sanitizer/sanitizer_test.go

+ 11 - 1
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 := `<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>`