]> sjero.net Git - wget/commitdiff
stsc: better message for "unsupported schemes".
authorMicah Cowan <micah@cowan.name>
Mon, 4 Aug 2008 05:03:04 +0000 (22:03 -0700)
committerMicah Cowan <micah@cowan.name>
Mon, 4 Aug 2008 05:03:04 +0000 (22:03 -0700)
src/ChangeLog
src/html-url.c
src/recur.c
src/retr.c
src/url.c
src/url.h

index 3e08d0d86722e12b67c0f9209331c53d335f86cc..73e9bd3f46c0e1aab6bd3f3a97ab04ed20b3530b 100644 (file)
@@ -1,3 +1,11 @@
+2008-08-03  Steven Schubiger  <stsc@members.fsf.org>
+
+       * url.c, url.h (url_error): Better messages for unsupported
+       schemes, especially https.
+
+       * html-url.c, recur.c, retr.c: Adjust to new url_error
+       invocation, and free result.
+
 2008-07-17  Steven Schubiger  <stsc@members.fsf.org>
 
        * retr.c (retrieve_from_file): When given an URL as input file,
index 75bec7d97e7c56709fea35044385480466ea8cfb..95df8bf98e35b5d93b21da4003326fa5539b45f7 100644 (file)
@@ -729,9 +729,11 @@ get_urls_file (const char *file)
       url = url_parse (url_text, &up_error_code);
       if (!url)
         {
+          char *error = url_error (url_text, up_error_code);
           logprintf (LOG_NOTQUIET, _("%s: Invalid URL %s: %s\n"),
-                     file, url_text, url_error (up_error_code));
+                     file, url_text, error);
           xfree (url_text);
+          xfree (error);
           continue;
         }
       xfree (url_text);
index 729a14e91d9cc2e57dbdd54894a954bfcca41d5f..741ca823094a75c0fd760f44cd126dba88e81216 100644 (file)
@@ -196,8 +196,9 @@ retrieve_tree (const char *start_url)
 
   if (!start_url_parsed)
     {
-      logprintf (LOG_NOTQUIET, "%s: %s.\n", start_url,
-                 url_error (up_error_code));
+      char *error = url_error (start_url, up_error_code);
+      logprintf (LOG_NOTQUIET, "%s: %s.\n", start_url, error);
+      xfree (error);
       return URLERROR;
     }
 
index 0fc468377ab0d4f91abe8af6980882bea1505baa..857742979e397748f3932d566d77ecf0d89dcd7b 100644 (file)
@@ -628,8 +628,10 @@ retrieve_url (const char *origurl, char **file, char **newloc,
   u = url_parse (url, &up_error_code);
   if (!u)
     {
-      logprintf (LOG_NOTQUIET, "%s: %s.\n", url, url_error (up_error_code));
+      char *error = url_error (url, up_error_code);
+      logprintf (LOG_NOTQUIET, "%s: %s.\n", url, error);
       xfree (url);
+      xfree (error);
       return URLERROR;
     }
 
@@ -650,9 +652,11 @@ retrieve_url (const char *origurl, char **file, char **newloc,
       proxy_url = url_parse (proxy, &up_error_code);
       if (!proxy_url)
         {
+          char *error = url_error (proxy, up_error_code);
           logprintf (LOG_NOTQUIET, _("Error parsing proxy URL %s: %s.\n"),
-                     proxy, url_error (up_error_code));
+                     proxy, error);
           xfree (url);
+          xfree (error);
           RESTORE_POST_DATA;
           return PROXERR;
         }
@@ -726,11 +730,13 @@ retrieve_url (const char *origurl, char **file, char **newloc,
       newloc_parsed = url_parse (mynewloc, &up_error_code);
       if (!newloc_parsed)
         {
+          char *error = url_error (mynewloc, up_error_code);
           logprintf (LOG_NOTQUIET, "%s: %s.\n", escnonprint_uri (mynewloc),
-                     url_error (up_error_code));
+                     error);
           url_free (u);
           xfree (url);
           xfree (mynewloc);
+          xfree (error);
           RESTORE_POST_DATA;
           return result;
         }
index f5d621f9064ca4f4d68b8f3117361db9936e1d08..5d9cd91f51d90ec0957aba9561a76ae273f8f11d 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -619,7 +619,7 @@ static const char *parse_errors[] = {
 #define PE_NO_ERROR                     0
   N_("No error"),
 #define PE_UNSUPPORTED_SCHEME           1
-  N_("Unsupported scheme"),
+  N_("Unsupported scheme %s"),
 #define PE_INVALID_HOST_NAME            2
   N_("Invalid host name"),
 #define PE_BAD_PORT_NUMBER              3
@@ -886,11 +886,29 @@ url_parse (const char *url, int *error)
 /* Return the error message string from ERROR_CODE, which should have
    been retrieved from url_parse.  The error message is translated.  */
 
-const char *
-url_error (int error_code)
+char *
+url_error (const char *url, int error_code)
 {
   assert (error_code >= 0 && ((size_t) error_code) < countof (parse_errors));
-  return _(parse_errors[error_code]);
+
+  if (error_code == PE_UNSUPPORTED_SCHEME)
+    {
+      char *error, *p;
+      char *scheme = xstrdup (url);
+      assert (url_has_scheme (url));
+
+      if ((p = strchr (scheme, ':')))
+        *p = '\0';
+      if (!strcasecmp (scheme, "https"))
+        asprintf (&error, _("HTTPS support not compiled in"));
+      else
+        asprintf (&error, _(parse_errors[error_code]), quote (scheme));
+      xfree (scheme);
+
+      return error;
+    }
+  else
+    return xstrdup (_(parse_errors[error_code]));
 }
 
 /* Split PATH into DIR and FILE.  PATH comes from the URL and is
index 7c8bcfed92875dbd21e98084a798e5b10761c448..ce308f6f97d815c624e85dd5ecc78a9300af83d6 100644 (file)
--- a/src/url.h
+++ b/src/url.h
@@ -85,7 +85,7 @@ struct url
 char *url_escape (const char *);
 
 struct url *url_parse (const char *, int *);
-const char *url_error (int);
+char *url_error (const char *, int);
 char *url_full_path (const struct url *);
 void url_set_dir (struct url *, const char *);
 void url_set_file (struct url *, const char *);