opt.remote_encoding should not override opt.locale, add a force arguments to set_uri_encoding()

This commit is contained in:
Xavier Saint 2008-07-30 10:15:55 +02:00
parent 8c513ef487
commit b967d49f79
6 changed files with 10 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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