#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 17; use MarkdownParser; my $parser = MarkdownParser->new(); is( $parser->parse("[link text](http://example.com)"), "
\n", "Simple link" ); is( $parser->parse("[link with spaces](https://example.com/path)"), "\n", "Link with path" ); is( $parser->parse(""), "

Click me
\n", "JavaScript protocol blocked in links" ); is( $parser->parse("[Click me](data:text/html,)"), "Click me
\n", "Data protocol blocked in links" ); is( $parser->parse("[Click me](javascript:alert('XSS'))"), "Click me
\n", "Encoded JavaScript protocol blocked in links" ); is( $parser->parse(")"), "Image
\n", "JavaScript protocol blocked in images" ); 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" );