From 32aba4561f804cd5d20c1daf0143d1e1005f15eb Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Mon, 29 Jun 2009 03:29:16 -0700 Subject: [PATCH] Percent-coded value test. --- tests/ChangeLog | 5 +++ tests/Test-iri-percent.px | 87 +++++++++++++++++++++++++++++++++++++++ tests/run-px | 1 + 3 files changed, 93 insertions(+) create mode 100755 tests/Test-iri-percent.px diff --git a/tests/ChangeLog b/tests/ChangeLog index 3dfc60a3..ec66a345 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2009-06-29 Micah Cowan + + * run-px, Test-iri-percent.px: Added test for percent-coded value + preservation. + 2008-12-04 Micah Cowan (not copyrightable) * run-px, Test-idn-robots.px: Added test for robots-file diff --git a/tests/Test-iri-percent.px b/tests/Test-iri-percent.px new file mode 100755 index 00000000..158392df --- /dev/null +++ b/tests/Test-iri-percent.px @@ -0,0 +1,87 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use HTTPTest; + +# Just a sanity check to verify that %-encoded values are always left +# untouched. + +my $ccedilla_l15 = "\xE7"; +my $ccedilla_l15_pct = "%E7"; +my $eacute_l1 = "\xE9"; +my $eacute_u8 = "\xC3\xA9"; +my $eacute_u8_pct = "%C3%A9"; + +my $pageindex = < + + Main Page + + +

+ Link to page 1 La seule page en français. +

+ + +EOF + +my $pagefrancais = < + + La seule page en français + + + +

+

+ + +EOF + +# code, msg, headers, content +my %urls = ( + '/index.html' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=ISO-8859-15", + }, + content => $pageindex, + }, + "/hello_${ccedilla_l15_pct}${eacute_u8_pct}.html" => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/html; charset=UTF-8", + }, + content => $pagefrancais, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --iri -e robots=off --restrict-file-names=nocontrol -nH -r http://localhost:{{port}}/"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'index.html' => { + content => $pageindex, + }, + "hello_${ccedilla_l15}${eacute_u8}.html" => { + content => $pagefrancais, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-iri-percent", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 + diff --git a/tests/run-px b/tests/run-px index 3b5449bd..64e35052 100755 --- a/tests/run-px +++ b/tests/run-px @@ -36,6 +36,7 @@ my @tests = ( 'Test-idn-cmd.px', 'Test-idn-robots.px', 'Test-iri.px', + 'Test-iri-percent.px', 'Test-iri-disabled.px', 'Test-iri-forced-remote.px', 'Test-iri-list.px', -- 2.39.2