From b967d49f79b6e0ce73559bd30d231bddc2e4b232 Mon Sep 17 00:00:00 2001 From: Xavier Saint Date: Wed, 30 Jul 2008 10:15:55 +0200 Subject: [PATCH] opt.remote_encoding should not override opt.locale, add a force arguments to set_uri_encoding() --- src/iri.c | 4 ++-- src/iri.h | 4 ++-- src/main.c | 2 +- src/recur.c | 4 ++-- src/res.c | 2 +- src/retr.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/iri.c b/src/iri.c index 44a262b8..3ee99871 100644 --- a/src/iri.c +++ b/src/iri.c @@ -329,10 +329,10 @@ iri_free (struct iri *i) } void -set_uri_encoding (struct iri *i, char *charset) +set_uri_encoding (struct iri *i, char *charset, bool force) { DEBUGP (("[IRI uri = `%s'\n", quote (charset))); - if (opt.encoding_remote) + if (!force && opt.encoding_remote) return; if (i->uri_encoding) { diff --git a/src/iri.h b/src/iri.h index cdc5c7fd..e7f3fe3e 100644 --- a/src/iri.h +++ b/src/iri.h @@ -47,7 +47,7 @@ char *idn_decode (char *host); bool remote_to_utf8 (struct iri *i, const char *str, const char **new); struct iri *iri_new (void); void iri_free (struct iri *i); -void set_uri_encoding (struct iri *i, char *charset); +void set_uri_encoding (struct iri *i, char *charset, bool force); void set_content_encoding (struct iri *i, char *charset); #else /* ENABLE_IRI */ @@ -63,7 +63,7 @@ struct iri dummy_iri; #define remote_to_utf8(a,b,c) false #define iri_new() (&dummy_iri) #define iri_free(a) -#define set_uri_encoding(a,b) +#define set_uri_encoding(a,b,c) #define set_content_encoding(a,b) #endif /* ENABLE_IRI */ diff --git a/src/main.c b/src/main.c index 8cee194c..799e5d63 100644 --- a/src/main.c +++ b/src/main.c @@ -1206,7 +1206,7 @@ WARNING: Can't reopen standard output in binary mode;\n\ else { struct iri *i = iri_new (); - set_uri_encoding (i, opt.locale); + set_uri_encoding (i, opt.locale, true); status = retrieve_url (*t, &filename, &redirected_URL, NULL, &dt, opt.recursive, i); iri_free (i); diff --git a/src/recur.c b/src/recur.c index aa83e9a6..19ef8f1c 100644 --- a/src/recur.c +++ b/src/recur.c @@ -202,7 +202,7 @@ retrieve_tree (const char *start_url) int up_error_code; struct url *start_url_parsed; struct iri *i = iri_new (); - set_uri_encoding (i, opt.locale); + set_uri_encoding (i, opt.locale, true); start_url_parsed = url_parse (start_url, &up_error_code, i); if (!start_url_parsed) @@ -391,7 +391,7 @@ retrieve_tree (const char *start_url) blacklist, i)) { ci = iri_new (); - set_uri_encoding (ci, i->content_encoding); + set_uri_encoding (ci, i->content_encoding, false); url_enqueue (queue, ci, xstrdup (child->url->url), xstrdup (referer_url), depth + 1, child->link_expect_html, diff --git a/src/res.c b/src/res.c index 69abd12d..0320d034 100644 --- a/src/res.c +++ b/src/res.c @@ -542,7 +542,7 @@ res_retrieve_file (const char *url, char **file, struct iri *iri) /* Copy server URI encoding for a possible IDNA transformation, no need to encode the full URI in UTF-8 because "robots.txt" is plain ASCII */ - set_uri_encoding (i, iri->uri_encoding); + set_uri_encoding (i, iri->uri_encoding, false); i->utf8_encode = false; logputs (LOG_VERBOSE, _("Loading robots.txt; please ignore errors.\n")); diff --git a/src/retr.c b/src/retr.c index 691b8f51..111b745a 100644 --- a/src/retr.c +++ b/src/retr.c @@ -653,7 +653,7 @@ retrieve_url (const char *origurl, char **file, char **newloc, { /* sXXXav : could a proxy include a path ??? */ struct iri *pi = iri_new (); - set_uri_encoding (pi, opt.locale); + set_uri_encoding (pi, opt.locale, true); pi->utf8_encode = false; /* Parse the proxy URL. */ @@ -1083,7 +1083,7 @@ url_uses_proxy (const char *url) struct url *u; struct iri *i = iri_new(); /* url was given in the command line, so use locale as encoding */ - set_uri_encoding (i, opt.locale); + set_uri_encoding (i, opt.locale, true); u= url_parse (url, NULL, i); if (!u) return false; -- 2.39.2