diff --git a/t/04-links-images.t b/t/04-links-images.t index 929bb73..e1a9f49 100755 --- a/t/04-links-images.t +++ b/t/04-links-images.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 17; use MarkdownParser; my $parser = MarkdownParser->new(); @@ -48,3 +48,38 @@ is( $parser->parse(""), "
Image
\n", "File protocol blocked in images" ); is( $parser->parse(")"), "Image
\n", "Encoded JavaScript protocol blocked in images" ); +is( + $parser->parse("[Click me](javascript :alert('XSS'))"), + "Click me
\n", + "JavaScript protocol with numeric newline entity blocked" +); +is( + $parser->parse("[Click me](java script:alert('XSS'))"), + "Click me
\n", + "JavaScript protocol with hex carriage return entity blocked" +); +is( + $parser->parse("[Click me](javascript%3Aalert('XSS'))"), + "Click me
\n", + "Mixed encoded JavaScript protocol blocked" +); +is( + $parser->parse(")"), + "Image
\n", + "JavaScript protocol with tab entity blocked in images" +); +is( + $parser->parse("[email](mailto:user\@example.com)"), + "\n", + "Mailto protocol remains allowed" +); +is( + $parser->parse("[safe](%68%74%74%70%73://example.com/path)"), + "\n", + "Percent-encoded https scheme remains allowed" +); +is( + $parser->parse("[relative](/docs/java script:guide)"), + "\n", + "Relative URL with colon in path remains allowed" +);