#include "utils.h"
#include "iri.h"
+/* RFC3987 section 3.1 mandates STD3 ASCII RULES */
+#define IDNA_FLAGS IDNA_USE_STD3_ASCII_RULES
+
/* Note: locale encoding is kept in options struct (opt.locale) */
/* Hold the encoding used for the current fetch */
}
/* toASCII UTF-8 NULL terminated string */
- ret = idna_to_ascii_8z (host, &new, 0);
+ ret = idna_to_ascii_8z (host, &new, IDNA_FLAGS);
if (ret != IDNA_SUCCESS)
{
/* sXXXav : free new when needed ! */
char *new;
int ret;
- ret = idna_to_unicode_8zlz (host, &new, 0);
+ ret = idna_to_unicode_8zlz (host, &new, IDNA_FLAGS);
if (ret != IDNA_SUCCESS)
{
logprintf (LOG_VERBOSE, "idn_decode failed (%d): %s\n", ret,
{
/*printf("[ current = `%s'\n", charset);*/
if (current)
- xfree (current);
+ {
+ /* Do nothing if already equal */
+ if (!strcasecmp (current, charset))
+ return;
+ xfree (current);
+ }
current = charset ? xstrdup (charset) : NULL;
}
void set_current_as_locale (void)
{
+ /* sXXXav : assert opt.locale NULL ? */
/*printf("[ current = locale = `%s'\n", opt.locale);*/
if (current)
- xfree (current);
+ {
+ if (!strcasecmp (current, opt.locale))
+ return;
+ xfree (current);
+ }
- /* sXXXav : assert opt.locale NULL ? */
current = xstrdup (opt.locale);
}
{
/*printf("[ remote = `%s'\n", charset);*/
if (remote)
- xfree (remote);
-
+ {
+ /* Do nothing if already equal */
+ if (!strcasecmp (remote, charset))
+ return;
+ xfree (remote);
+ }
remote = charset ? xstrdup (charset) : NULL;
}
{
/*printf("[ remote = current = `%s'\n", current);*/
if (remote)
- xfree (remote);
+ {
+ /* Do nothing if already equal */
+ if (current && !strcasecmp (remote, current))
+ return;
+ xfree (remote);
+ }
remote = current ? xstrdup (current) : NULL;
}
bool get_utf8_encode (void)
{
- return utf8_encode;
+ return (!ugly_no_encode && utf8_encode);
}
void set_ugly_no_encode (bool ugly)
ugly_no_encode = ugly;
}
-bool get_ugly_no_encode (void)
-{
- return ugly_no_encode;
-}
-