]> sjero.net Git - wget/commitdiff
iri: Fix parsing of some URLs contained in HTML documents
authorGiuseppe Scrivano <gscrivan@redhat.com>
Thu, 10 Oct 2013 21:13:13 +0000 (23:13 +0200)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Thu, 10 Oct 2013 21:13:13 +0000 (23:13 +0200)
src/ChangeLog
src/html-url.c
src/url.c

index 43997f88d5ae2111616c698e72e4682e7d341914..81320ca48f206876daf1cb3e54eb21df76785f1a 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-10  Giuseppe Scrivano  <gscrivan@redhat.com>
+
+       * url.c (url_parse): Try to convert UTF-8 URLs to IDN.
+       * html-url.c (append_url): Parse URLs specifying an IRI structure.
+
 2013-09-13  Tim Ruehsen  <tim.ruehsen@gmx.de>
 
        * recur.c (download_child_p): fix compile error when
index bb2b20e316b3db9896bee39ee1c4df84830a5435..1bb44b467b27ea57ca9a89185f3c63a9fcf8d4d1 100644 (file)
@@ -284,6 +284,10 @@ append_url (const char *link_uri, int position, int size,
   const char *base = ctx->base ? ctx->base : ctx->parent_base;
   struct url *url;
 
+  struct iri *iri = iri_new ();
+  set_uri_encoding (iri, opt.locale, true);
+  iri->utf8_encode = true;
+
   if (!base)
     {
       DEBUGP (("%s: no base, merge will use \"%s\".\n",
@@ -301,7 +305,7 @@ append_url (const char *link_uri, int position, int size,
           return NULL;
         }
 
-      url = url_parse (link_uri, NULL, NULL, false);
+      url = url_parse (link_uri, NULL, iri, false);
       if (!url)
         {
           DEBUGP (("%s: link \"%s\" doesn't parse.\n",
@@ -323,7 +327,7 @@ append_url (const char *link_uri, int position, int size,
                quote_n (2, link_uri),
                quotearg_n_style (3, escape_quoting_style, complete_uri)));
 
-      url = url_parse (complete_uri, NULL, NULL, false);
+      url = url_parse (complete_uri, NULL, iri, false);
       if (!url)
         {
           DEBUGP (("%s: merged link \"%s\" doesn't parse.\n",
@@ -334,6 +338,8 @@ append_url (const char *link_uri, int position, int size,
       xfree (complete_uri);
     }
 
+  iri_free (iri);
+
   DEBUGP (("appending %s to urlpos.\n", quote (url->url)));
 
   newel = xnew0 (struct urlpos);
index bf9d6971de49e52f75762aa7a2c4d174a7eb41c1..f554432c081280cc56cade20ddc98d6f28ec07a1 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -701,7 +701,10 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
       if (!iri->utf8_encode)
         new_url = NULL;
       else
-        iri->orig_url = xstrdup (url);
+        {
+          iri->orig_url = xstrdup (url);
+          percent_encode = true;
+        }
     }
 
   /* XXX XXX Could that change introduce (security) bugs ???  XXX XXX*/