]> sjero.net Git - wget/blobdiff - src/url.c
Make get_utf8_encode() directly aware of ugly_no_encode and remove get_ugly_no_encode()
[wget] / src / url.c
index f5d621f9064ca4f4d68b8f3117361db9936e1d08..beaf0fb204e67c2941a03c6cad6d87cd11b3d2b5 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -42,6 +42,7 @@ as that of the covered work.  */
 #include "utils.h"
 #include "url.h"
 #include "host.h"  /* for is_valid_ipv6_address */
+#include "iri.h"
 
 #ifdef TESTING
 #include "test.h"
@@ -670,6 +671,17 @@ url_parse (const char *url, int *error)
       goto error;
     }
 
+  if (opt.enable_iri && get_utf8_encode ())
+    {
+      const char *new;
+      bool utf8_encode;
+      url_unescape ((char *) url);
+      utf8_encode = remote_to_utf8 (url, &new);
+      set_utf8_encode (utf8_encode);
+      if (utf8_encode)
+        url = new;
+    }
+
   url_encoded = reencode_escapes (url);
   p = url_encoded;
 
@@ -844,6 +856,17 @@ url_parse (const char *url, int *error)
       host_modified = true;
     }
 
+  if (opt.enable_iri)
+    {
+      char *new = idn_encode (u->host, get_utf8_encode ());
+      if (new)
+        {
+          xfree (u->host);
+          u->host = new;
+          host_modified = true;
+        }
+    }
+
   if (params_b)
     u->params = strdupdelim (params_b, params_e);
   if (query_b)
@@ -851,7 +874,7 @@ url_parse (const char *url, int *error)
   if (fragment_b)
     u->fragment = strdupdelim (fragment_b, fragment_e);
 
-  if (path_modified || u->fragment || host_modified || path_b == path_e)
+  if (opt.enable_iri || path_modified || u->fragment || host_modified || path_b == path_e)
     {
       /* If we suspect that a transformation has rendered what
          url_string might return different from URL_ENCODED, rebuild