fix data:image handling 1.33.4
authorJoey Hess <joey@kodama.kitenet.net>
Sun, 10 Feb 2008 20:28:48 +0000 (15:28 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Sun, 10 Feb 2008 20:28:48 +0000 (15:28 -0500)
IkiWiki/Plugin/htmlscrubber.pm
t/htmlize.t

index 60ad17baf224ef4cdbd56d87b4ee717770a6625d..c83ffb48d182707ca3ce1ffc828fa15159a8ca9d 100644 (file)
@@ -29,16 +29,15 @@ sub scrubber { #{{{
                "ldap", "mid", "news", "nfs", "nntp", "pop", "pres",
                "sip", "sips", "snmp", "tel", "urn", "wais", "xmpp",
                "z39.50r", "z39.50s",
-               # data is a special case. Allow data:text/<image>, but
-               # disallow data:text/javascript and everything else.
-               qr/data:text\/(?:png|gif|jpeg)/,
                # Selected unofficial schemes
                "about", "aim", "callto", "cvs", "ed2k", "feed", "fish", "gg",
                "irc", "ircs", "lastfm", "ldaps", "magnet", "mms",
                "msnim", "notes", "rsync", "secondlife", "skype", "ssh",
                "sftp", "sms", "steam", "webcal", "ymsgr",
        );
-       my $link=qr/^(?:$uri_schemes:|[^:]+$)/i;
+       # data is a special case. Allow data:image/*, but
+       # disallow data:text/javascript and everything else.
+       my $link=qr/^(?:$uri_schemes:|data:image\/|[^:]+$)/i;
 
        eval q{use HTML::Scrubber};
        error($@) if $@;
index 0be94ab6b91e69a9106ef76a133fabc8baf6c75a..bbebdac635267c25f90ba55478ca03c9a87f5a3f 100755 (executable)
@@ -46,11 +46,11 @@ ok(!gotcha(q{<video poster="javascript:alert('GOTCHA')" href="foo.avi">foo</vide
        "video poster with javascript");
 ok(!gotcha(q{<span style="background: url(javascript:window.location=GOTCHA)">a</span>}),
        "CSS script test");
-ok(! gotcha(q{<img src="data:text/javascript:GOTCHA">}),
+ok(! gotcha(q{<img src="data:text/javascript;GOTCHA">}),
        "data:text/javascript (jeez!)");
-ok(gotcha(q{<img src="data:text/png:GOTCHA">}), "data:text/png");
-ok(gotcha(q{<img src="data:text/gif:GOTCHA">}), "data:text/gif");
-ok(gotcha(q{<img src="data:text/jpeg:GOTCHA">}), "data:text/jpeg");
+ok(gotcha(q{<img src="data:image/png;base64,GOTCHA">}), "data:image/png");
+ok(gotcha(q{<img src="data:image/gif;base64,GOTCHA">}), "data:image/gif");
+ok(gotcha(q{<img src="data:image/jpeg;base64,GOTCHA">}), "data:image/jpeg");
 ok(gotcha(q{<p>javascript:alert('GOTCHA')</p>}),
        "not javascript AFAIK (but perhaps some web browser would like to
        be perverse and assume it is?)");