]> sjero.net Git - wget/blob - tests/Test-iri-percent.px
NEWS: cite --start-pos
[wget] / tests / Test-iri-percent.px
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use WgetFeature qw(iri);
7 use HTTPTest;
8
9 # Just a sanity check to verify that %-encoded values are always left
10 # untouched.
11
12 my $ccedilla_l15 = "\xE7";
13 my $ccedilla_l15_pct = "%E7";
14 my $eacute_l1 = "\xE9";
15 my $eacute_u8 = "\xC3\xA9";
16 my $eacute_u8_pct = "%C3%A9";
17
18 my $pageindex = <<EOF;
19 <html>
20 <head>
21   <title>Main Page</title>
22 </head>
23 <body>
24   <p>
25     Link to page 1 <a
26     href="http://localhost:{{port}}/hello_${ccedilla_l15_pct}${eacute_l1}.html">La seule page en fran&ccedil;ais</a>.
27   </p>
28 </body>
29 </html>
30 EOF
31
32 my $pagefrancais = <<EOF;
33 <html>
34 <head>
35   <title>La seule page en français</title>
36   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
37 </head>
38 <body>
39   <p>
40   </p>
41 </body>
42 </html>
43 EOF
44
45 # code, msg, headers, content
46 my %urls = (
47     '/index.html' => {
48         code => "200",
49         msg => "Ok",
50         headers => {
51             "Content-type" => "text/html; charset=ISO-8859-15",
52         },
53         content => $pageindex,
54     },
55     "/hello_${ccedilla_l15_pct}${eacute_u8_pct}.html" => {
56         code => "200",
57         msg => "Ok",
58         headers => {
59             "Content-type" => "text/html; charset=UTF-8",
60         },
61         content => $pagefrancais,
62     },
63 );
64
65 my $cmdline = $WgetTest::WGETPATH . " --iri -e robots=off --restrict-file-names=nocontrol -nH -r http://localhost:{{port}}/";
66
67 my $expected_error_code = 0;
68
69 my %expected_downloaded_files = (
70     'index.html' => {
71         content => $pageindex,
72     },
73     "hello_${ccedilla_l15}${eacute_u8}.html" => {
74         content => $pagefrancais,
75     },
76 );
77
78 ###############################################################################
79
80 my $the_test = HTTPTest->new (name => "Test-iri-percent",
81                               input => \%urls,
82                               cmdline => $cmdline,
83                               errcode => $expected_error_code,
84                               output => \%expected_downloaded_files);
85 exit $the_test->run();
86
87 # vim: et ts=4 sw=4
88