| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use HTTPTest; |
| 7 |
|
| 8 |
# This program tests that --restrict-file-names=ascii can be used to |
| 9 |
# ensure that all high-valued bytes are escaped. The sample filename was |
| 10 |
# chosen because in former versions of Wget, one could either choose not |
| 11 |
# to escape any portion of the UTF-8 filename via |
| 12 |
# --restrict-file-names=nocontrol (which would only be helpful if one |
| 13 |
# was _on_ a UTF-8 system), or else Wget would escape _portions_ of |
| 14 |
# characters, leaving irrelevant "latin1"-looking characters combined |
| 15 |
# with percent-encoded "control" characters, instead of encoding all the |
| 16 |
# bytes of an entire non-ASCII UTF-8 character. |
| 17 |
|
| 18 |
############################################################################### |
| 19 |
|
| 20 |
# "gnosis" in UTF-8 greek. |
| 21 |
my $gnosis = '%CE%B3%CE%BD%CF%89%CF%83%CE%B9%CF%82'; |
| 22 |
|
| 23 |
my $mainpage = <<EOF; |
| 24 |
<html> |
| 25 |
<head> |
| 26 |
<title>Some Page Title</title> |
| 27 |
</head> |
| 28 |
<body> |
| 29 |
<p> |
| 30 |
Some text... |
| 31 |
</p> |
| 32 |
</body> |
| 33 |
</html> |
| 34 |
EOF |
| 35 |
|
| 36 |
# code, msg, headers, content |
| 37 |
my %urls = ( |
| 38 |
"/$gnosis.html" => { |
| 39 |
code => "200", |
| 40 |
msg => "Dontcare", |
| 41 |
headers => { |
| 42 |
"Content-type" => "text/html", |
| 43 |
}, |
| 44 |
content => $mainpage, |
| 45 |
}, |
| 46 |
); |
| 47 |
|
| 48 |
my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=ascii " |
| 49 |
. "http://localhost:{{port}}/${gnosis}.html"; |
| 50 |
|
| 51 |
my $expected_error_code = 0; |
| 52 |
|
| 53 |
my %expected_downloaded_files = ( |
| 54 |
"${gnosis}.html" => { |
| 55 |
content => $mainpage, |
| 56 |
}, |
| 57 |
); |
| 58 |
|
| 59 |
############################################################################### |
| 60 |
|
| 61 |
my $the_test = HTTPTest->new (input => \%urls, |
| 62 |
cmdline => $cmdline, |
| 63 |
errcode => $expected_error_code, |
| 64 |
output => \%expected_downloaded_files); |
| 65 |
exit $the_test->run(); |
| 66 |
|
| 67 |
# vim: et ts=4 sw=4 |