URLDecode: Adding guard for percent encoded content

master
Rob Emery 2014-09-08 20:12:02 +01:00
parent eede9244b0
commit 6aa39b9552
2 changed files with 4 additions and 5 deletions

View File

@ -27,6 +27,7 @@ sub append_css {
};
handle remainder => sub {
return unless /\+|%[0-9a-fA-F]{2}/;
my $decoded_url = decodeURIComponent($_);
my $text = "URL: $decoded_url";

View File

@ -44,15 +44,13 @@ ddg_goodie_test(
'URL: www.heroku.com/{rawwr!@#$%^&*()+=__}',
html => qr|www\.heroku\.com/\{rawwr!@#\$%\^&\*\(\)\+=__\}|
),
'hello there unescapeurl' => test_zci(
"URL: hello there",
html => qr#hello there#
),
'hello there unescapeurl' => undef,
'urldecode %3Cscript%3Ealert(1)%3C%2Fscript%3E' => test_zci(
"URL: <script>alert(1)</script>",
html => qr|&lt;script&gt;alert\(1\)&lt;/script&gt;|
),
'url decode tool' => undef,
'url decode online' => undef
);
done_testing;