1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

stsc: better message for "unsupported schemes".

This commit is contained in:
Micah Cowan 2008-08-03 22:03:04 -07:00
parent e4371807f6
commit 0fae9cb388
6 changed files with 46 additions and 11 deletions

View 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,

View 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);

View 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;
}

View 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;
}

View File

@ -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

View File

@ -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 *);