Debian Codegraph @

tests/Test-iri-percent.px

raw
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 $ccedilla_u8 = "\xC3\xA7";
15 my $ccedilla_u8_pct = "%C3%A7";
16 my $eacute_l1 = "\xE9";
17 my $eacute_u8 = "\xC3\xA9";
18 my $eacute_u8_pct = "%C3%A9";
19
20 my $pageindex = <<EOF;
21 <html>
22 <head>
23 <title>Main Page</title>
24 </head>
25 <body>
26 <p>
27 Link to page 1 <a
28 href="http://localhost:{{port}}/hello_${ccedilla_l15_pct}${eacute_l1}.html">La seule page en fran&ccedil;ais</a>.
29 </p>
30 </body>
31 </html>
32 EOF
33
34 my $pagefrancais = <<EOF;
35 <html>
36 <head>
37 <title>La seule page en français</title>
38 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
39 </head>
40 <body>
41 <p>
42 </p>
43 </body>
44 </html>
45 EOF
46
47 # code, msg, headers, content
48 my %urls = (
49 '/index.html' => {
50 code => "200",
51 msg => "Ok",
52 headers => {
53 "Content-type" => "text/html; charset=ISO-8859-15",
54 },
55 content => $pageindex,
56 },
57 "/hello_${ccedilla_u8_pct}${eacute_u8_pct}.html" => {
58 code => "200",
59 msg => "Ok",
60 headers => {
61 "Content-type" => "text/html; charset=UTF-8",
62 },
63 content => $pagefrancais,
64 },
65 );
66
67 my $cmdline = $WgetTest::WGETPATH . " --iri -e robots=off --restrict-file-names=nocontrol -nH -r http://localhost:{{port}}/";
68
69 my $expected_error_code = 0;
70
71 my %expected_downloaded_files = (
72 'index.html' => {
73 content => $pageindex,
74 },
75 "hello_${ccedilla_u8}${eacute_u8}.html" => {
76 content => $pagefrancais,
77 },
78 );
79
80 ###############################################################################
81
82 my $the_test = HTTPTest->new (input => \%urls,
83 cmdline => $cmdline,
84 errcode => $expected_error_code,
85 output => \%expected_downloaded_files);
86 exit $the_test->run();
87
88 # vim: et ts=4 sw=4