2014-09-07 12:49:55 -07:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => 'decoded_url';
|
2014-10-10 02:45:06 -07:00
|
|
|
zci is_cached => 1;
|
2014-09-07 12:49:55 -07:00
|
|
|
|
|
|
|
ddg_goodie_test(
|
|
|
|
[qw(DDG::Goodie::URLDecode)],
|
|
|
|
|
|
|
|
# Primary example queries
|
|
|
|
'url decode https%3A%2F%2Fduckduckgo.com%2F' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: https://duckduckgo.com/",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['https%3A%2F%2Fduckduckgo.com%2F'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'https://duckduckgo.com/'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'decode url xkcd.com%2Fblag' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: xkcd.com/blag",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['xkcd.com%2Fblag'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'xkcd.com/blag'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
# Secondary example queries
|
|
|
|
'http%3A%2F%2Farstechnica.com%2F url unescape' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: http://arstechnica.com/",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['http%3A%2F%2Farstechnica.com%2F'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'http://arstechnica.com/'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'linux.com%2Ftour%2F unescape url' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: linux.com/tour/",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['linux.com%2Ftour%2F'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'linux.com/tour/'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'urldecode www.xkcd.com%2Fa-webcomic-of-romance%2Bmath%2Bsarcasm%2Blanguage' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: www.xkcd.com/a-webcomic-of-romance+math+sarcasm+language",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['www.xkcd.com%2Fa-webcomic-of-romance%2Bmath%2Bsarcasm%2Blanguage'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'www.xkcd.com/a-webcomic-of-romance+math+sarcasm+language'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'unescapeurl https%3A%2F%2Fexample.com%2Fzero%23clickinfo%5E%3Cgoodies%3E%3Bspice%3Afathead-%5C' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
'URL Decoded: https://example.com/zero#clickinfo^<goodies>;spice:fathead-\\',
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['https%3A%2F%2Fexample.com%2Fzero%23clickinfo%5E%3Cgoodies%3E%3Bspice%3Afathead-%5C'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'https://example.com/zero#clickinfo^<goodies>;spice:fathead-\\'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'urlunescape https%3A%2F%2Fexample.org%2Fthe%20answer%20to%20%22%5Blife%5D%2C%20(the%20universe)%20.and.%20%3Ceverything%3E%22' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
qq`URL Decoded: https://example.org/the answer to "[life], (the universe) .and. <everything>"`,
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['https%3A%2F%2Fexample.org%2Fthe%20answer%20to%20%22%5Blife%5D%2C%20(the%20universe)%20.and.%20%3Ceverything%3E%22'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'https://example.org/the answer to "[life], (the universe) .and. <everything>"'
|
|
|
|
}
|
2014-09-10 15:26:00 -07:00
|
|
|
),
|
|
|
|
'https%3A%2F%2Fexample.org%2Fthe%20answer%20to%20%22%5Blife%5D%2C%20(the%20universe)%20.and.%20%3Ceverything%3E%22' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
qq`URL Decoded: https://example.org/the answer to "[life], (the universe) .and. <everything>"`,
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['https%3A%2F%2Fexample.org%2Fthe%20answer%20to%20%22%5Blife%5D%2C%20(the%20universe)%20.and.%20%3Ceverything%3E%22'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'https://example.org/the answer to "[life], (the universe) .and. <everything>"'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'www.heroku.com%2F%7Brawwr!%40%23%24%25%5E%26*()%2B%3D__%7D unescapeurl' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
'URL Decoded: www.heroku.com/{rawwr!@#$%^&*()+=__}',
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['www.heroku.com%2F%7Brawwr!%40%23%24%25%5E%26*()%2B%3D__%7D'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'www.heroku.com/{rawwr!@#$%^&*()+=__}'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
|
|
|
'urldecode %3Cscript%3Ealert(1)%3C%2Fscript%3E' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: <script>alert(1)</script>",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['%3Cscript%3Ealert(1)%3C%2Fscript%3E'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => '<script>alert(1)</script>'
|
|
|
|
}
|
2014-09-07 12:49:55 -07:00
|
|
|
),
|
2014-09-10 14:49:31 -07:00
|
|
|
'https%3A%2F%2Fduckduckgo.com%2F' => test_zci(
|
2014-09-17 12:04:08 -07:00
|
|
|
"URL Decoded: https://duckduckgo.com/",
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['https%3A%2F%2Fduckduckgo.com%2F'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'https://duckduckgo.com/'
|
|
|
|
}
|
2014-09-10 14:49:31 -07:00
|
|
|
),
|
2014-09-18 12:15:14 -07:00
|
|
|
'%20' => test_zci(
|
|
|
|
'URL Decoded: Space',
|
2014-10-10 02:45:06 -07:00
|
|
|
structured_answer => {
|
|
|
|
input => ['%20'],
|
|
|
|
operation => 'URL decode',
|
|
|
|
result => 'Space'
|
|
|
|
}
|
2014-09-18 12:15:14 -07:00
|
|
|
),
|
2014-10-10 02:45:06 -07:00
|
|
|
'hello there unescapeurl' => undef,
|
|
|
|
'38% of 100 GBP' => undef,
|
|
|
|
'url decode tool' => undef,
|
|
|
|
'url decode online' => undef
|
2014-09-07 12:49:55 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|