1#!/usr/bin/perl 2 3use strict; 4use warnings; 5 6use 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. 21my $gnosis = '%CE%B3%CE%BD%CF%89%CF%83%CE%B9%CF%82'; 22 23my $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> 34EOF 35 36# code, msg, headers, content 37my %urls = ( 38 "/$gnosis.html" => { 39 code => "200", 40 msg => "Dontcare", 41 headers => { 42 "Content-type" => "text/html", 43 }, 44 content => $mainpage, 45 }, 46); 47 48my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=ascii " 49 . "http://localhost:{{port}}/${gnosis}.html"; 50 51my $expected_error_code = 0; 52 53my %expected_downloaded_files = ( 54 "${gnosis}.html" => { 55 content => $mainpage, 56 }, 57); 58 59############################################################################### 60 61my $the_test = HTTPTest->new (name => "Test-restrict-ascii", 62 input => \%urls, 63 cmdline => $cmdline, 64 errcode => $expected_error_code, 65 output => \%expected_downloaded_files); 66exit $the_test->run(); 67 68# vim: et ts=4 sw=4 69 70