]> sjero.net Git - wget/blobdiff - src/url.c
Automated merge.
[wget] / src / url.c
index 31614794cfd3411614b708939264653a1d284546..86d099a7190b80aaec8bc1cf6771c49892364602 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -649,7 +649,7 @@ static const char *parse_errors[] = {
    error, and if ERROR is not NULL, also set *ERROR to the appropriate
    error code. */
 struct url *
-url_parse (const char *url, int *error, struct iri *iri)
+url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
 {
   struct url *u;
   const char *p;
@@ -681,13 +681,19 @@ url_parse (const char *url, int *error, struct iri *iri)
 
   if (iri && iri->utf8_encode)
     {
-      url_unescape ((char *) url);
-      iri->utf8_encode = remote_to_utf8 (iri, url, (const char **) &new_url);
+      iri->utf8_encode = remote_to_utf8 (iri, iri->orig_url ? iri->orig_url : url, (const char **) &new_url);
       if (!iri->utf8_encode)
         new_url = NULL;
+      else
+        iri->orig_url = xstrdup (url);
     }
 
-  url_encoded = reencode_escapes (new_url ? new_url : url);
+  /* XXX XXX Could that change introduce (security) bugs ???  XXX XXX*/
+  if (percent_encode)
+    url_encoded = reencode_escapes (new_url ? new_url : url);
+  else
+     url_encoded = new_url ? new_url : url;
+
   p = url_encoded;
 
   if (new_url && url_encoded != new_url)
@@ -2001,12 +2007,12 @@ schemes_are_similar_p (enum url_scheme a, enum url_scheme b)
 \f
 static int
 getchar_from_escaped_string (const char *str, char *c)
-{  
+{
   const char *p = str;
 
   assert (str && *str);
   assert (c);
-  
+
   if (p[0] == '%')
     {
       if (!c_isxdigit(p[1]) || !c_isxdigit(p[2]))
@@ -2056,7 +2062,7 @@ are_urls_equal (const char *u1, const char *u2)
       p += pp;
       q += qq;
     }
-  
+
   return (*p == 0 && *q == 0 ? true : false);
 }
 \f
@@ -2165,7 +2171,7 @@ test_append_uri_pathel()
   } test_array[] = {
     { "http://www.yoyodyne.com/path/", "somepage.html", false, "http://www.yoyodyne.com/path/somepage.html" },
   };
-  
+
   for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i) 
     {
       struct growable dest;