]> sjero.net Git - wget/commitdiff
Escape semicolons when converting links (#27272).
authorSteven Schubiger <stsc@member.fsf.org>
Sat, 29 Aug 2009 21:24:49 +0000 (23:24 +0200)
committerSteven Schubiger <stsc@member.fsf.org>
Sat, 29 Aug 2009 21:24:49 +0000 (23:24 +0200)
src/ChangeLog
src/convert.c
tests/ChangeLog
tests/Test-k.px [new file with mode: 0755]
tests/run-px

index 7a096ef32138edf49aa78cfa778fb76b6eee7c71..caad2a27393ab3ffe8f31c95af564e74326dcecb 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-29  Steven Schubiger  <stsc@member.fsf.org>
+
+       * convert.c (local_quote_string): Percent-encode semicolons
+       in local file strings.
+
 2009-08-27  Micah Cowan  <micah@cowan.name>
 
        * wget.h (uerr_t): added new VERIFCERTERR code for SSL certificate
index 71e3d8f03a4346a96565152158d55a43c4f18951..653c7b4d97d960345b5d071e1130fca5d0817265 100644 (file)
@@ -1,6 +1,6 @@
 /* Conversion of links to local files.
    Copyright (C) 2003, 2004, 2005, 2006, 2007,
-   2008 Free Software Foundation, Inc.
+   2008, 2009 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -598,8 +598,8 @@ find_fragment (const char *beg, int size, const char **bp, const char **ep)
    "index.html?foo=bar.html" to "index.html%3Ffoo=bar.html" should be
    safe for both local and HTTP-served browsing.
 
-   We always quote "#" as "%23" and "%" as "%25" because those
-   characters have special meanings in URLs.  */
+   We always quote "#" as "%23", "%" as "%25" and ";" as "%3B"
+   because those characters have special meanings in URLs.  */
 
 static char *
 local_quote_string (const char *file)
@@ -607,7 +607,7 @@ local_quote_string (const char *file)
   const char *from;
   char *newname, *to;
 
-  char *any = strpbrk (file, "?#%");
+  char *any = strpbrk (file, "?#%;");
   if (!any)
     return html_quote_string (file);
 
@@ -627,6 +627,11 @@ local_quote_string (const char *file)
         *to++ = '2';
         *to++ = '3';
         break;
+      case ';':
+        *to++ = '%';
+        *to++ = '3';
+        *to++ = 'B';
+        break;
       case '?':
         if (opt.adjust_extension)
           {
index f5e4f348029a00767426168513e531d14316e198..2a5c097fb0213ff36059d4acac8ab1e95d69e348 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-29  Steven Schubiger  <stsc@member.fsf.org>
+
+       * run-px: Add Test-k.px to the list.
+
+       * Test-k.px: Test escaping of semicolons in local file strings.
+
 2009-08-27  Micah Cowan  <micah@cowan.name>
 
        * WgetTest.pm.in (run): Shift the errcode right by 8 binary places.
diff --git a/tests/Test-k.px b/tests/Test-k.px
new file mode 100755 (executable)
index 0000000..d94fb3b
--- /dev/null
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $index = <<EOF;
+<html>
+  <head>
+    <title>Index</title>
+  </head>
+  <body>
+    <a href="site;sub:.html">Site</a>
+  </body>
+</html>
+EOF
+
+my $converted = <<EOF;
+<html>
+  <head>
+    <title>Index</title>
+  </head>
+  <body>
+    <a href="site%3Bsub:.html">Site</a>
+  </body>
+</html>
+EOF
+
+my $site = <<EOF;
+<html>
+  <head>
+    <title>Site</title>
+  </head>
+  <body>
+    Subsite
+  </body>
+</html>
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/index.html' => {
+        code => "200",
+        msg => "Ok",
+        headers => {
+            "Content-type" => "text/html",
+        },
+        content => $index,
+    },
+    '/site;sub:.html' => {
+        code => "200",
+        msg => "Ok",
+        headers => {
+            "Content-type" => "text/html",
+        },
+        content => $site,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -k -r -nH http://localhost:{{port}}/index.html";
+
+my $expected_error_code = 0;
+
+my %expected_downloaded_files = (
+    'index.html' => {
+        content => $converted,
+    },
+    'site;sub:.html' => {
+        content => $site,
+    },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-k",
+                              input => \%urls,
+                              cmdline => $cmdline,
+                              errcode => $expected_error_code,
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
index e4e7c7dcad1818edb5e3f6e8c1db9d21d32345d1..5dade1bd7e72a3c00c2771cc81037956bfe4378c 100755 (executable)
@@ -43,6 +43,7 @@ my @tests = (
     'Test-iri-disabled.px',
     'Test-iri-forced-remote.px',
     'Test-iri-list.px',
+    'Test-k.px',
     'Test-meta-robots.px',
     'Test-N-current.px',
     'Test-N-smaller.px',