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

Improve HTML sanitizer

This commit is contained in:
Frédéric Guillot 2017-11-25 18:08:59 -08:00
parent 1f015d5dfe
commit bd663b43a0
4 changed files with 28 additions and 7 deletions

View file

@ -142,3 +142,23 @@ func TestPixelTracker(t *testing.T) {
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>`
output := Sanitize("http://example.org/", input)
if expected != output {
t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
}
}
func TestEspaceAttributes(t *testing.T) {
input := `<td rowspan="<b>test</b>">test</td>`
expected := `<td rowspan="&lt;b&gt;test&lt;/b&gt;">test</td>`
output := Sanitize("http://example.org/", input)
if expected != output {
t.Errorf(`Wrong output: "%s" != "%s"`, expected, output)
}
}