]> sjero.net Git - wget/blobdiff - src/url.c
Quote some things that needed quoting.
[wget] / src / url.c
index 8f0672503f07fdfef8cde9b8b4093b4b63841c71..6b24e0637331c0fa28e9e5fa96a24ee6667b64ee 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -252,6 +252,15 @@ url_escape (const char *s)
   return url_escape_1 (s, urlchr_unsafe, false);
 }
 
+/* URL-escape the unsafe and reserved characters (see urlchr_table) in
+   a given string, returning a freshly allocated string.  */
+
+char *
+url_escape_unsafe_and_reserved (const char *s)
+{
+  return url_escape_1 (s, urlchr_unsafe|urlchr_reserved, false);
+}
+
 /* URL-escape the unsafe characters (see urlchr_table) in a given
    string.  If no characters are unsafe, S is returned.  */
 
@@ -659,7 +668,8 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
   int port;
   char *user = NULL, *passwd = NULL;
 
-  char *url_encoded = NULL, *new_url = NULL;
+  const char *url_encoded = NULL;
+  char *new_url = NULL;
 
   int error_code;
 
@@ -683,7 +693,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
   if (percent_encode)
     url_encoded = reencode_escapes (new_url ? new_url : url);
   else
-     url_encoded = new_url ? new_url : url;
+    url_encoded = new_url ? new_url : url;
 
   p = url_encoded;
 
@@ -895,7 +905,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
       if (url_encoded == url)
         u->url = xstrdup (url);
       else
-        u->url = url_encoded;
+        u->url = (char *) url_encoded;
     }
 
   return u;
@@ -903,7 +913,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
  error:
   /* Cleanup in case of error: */
   if (url_encoded && url_encoded != url)
-    xfree (url_encoded);
+    xfree ((char *) url_encoded);
 
   /* Transmit the error code to the caller, if the caller wants to
      know.  */
@@ -929,9 +939,9 @@ url_error (const char *url, int error_code)
       if ((p = strchr (scheme, ':')))
         *p = '\0';
       if (!strcasecmp (scheme, "https"))
-        asprintf (&error, _("HTTPS support not compiled in"));
+        error = aprintf (_("HTTPS support not compiled in"));
       else
-        asprintf (&error, _(parse_errors[error_code]), quote (scheme));
+        error = aprintf (_(parse_errors[error_code]), quote (scheme));
       xfree (scheme);
 
       return error;