mirror of
https://github.com/mirror/wget.git
synced 2024-12-28 22:00:27 +08:00
* src/iri.c (idn_encode): Use TR46 transitional if available
This commit is contained in:
parent
60dc3c21b2
commit
0eb4a21b6c
12
src/iri.c
12
src/iri.c
@ -312,6 +312,14 @@ idn_encode (const struct iri *i, const char *host)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if IDN2_VERSION_NUMBER >= 0x00140000
|
||||
/* IDN2_TRANSITIONAL implies input NFC encoding */
|
||||
if ((ret = idn2_lookup_u8 (src, (uint8_t **) &ascii_encoded, IDN2_TRANSITIONAL)) != IDN2_OK)
|
||||
{
|
||||
logprintf (LOG_VERBOSE, _("idn_encode failed (%d): %s\n"), ret,
|
||||
quote (idn2_strerror (ret)));
|
||||
}
|
||||
#else
|
||||
/* we need a conversion to lowercase */
|
||||
lower = u8_tolower ((uint8_t *) src, u8_strlen ((uint8_t *) src) + 1, 0, UNINORM_NFKC, NULL, &len);
|
||||
if (!lower)
|
||||
@ -326,12 +334,12 @@ idn_encode (const struct iri *i, const char *host)
|
||||
{
|
||||
logprintf (LOG_VERBOSE, _("idn_encode failed (%d): %s\n"), ret,
|
||||
quote (idn2_strerror (ret)));
|
||||
ascii_encoded = NULL;
|
||||
}
|
||||
|
||||
xfree (lower);
|
||||
#endif
|
||||
|
||||
return ascii_encoded;
|
||||
return ret == IDN2_OK ? ascii_encoded : NULL;
|
||||
}
|
||||
|
||||
/* Try to decode an "ASCII encoded" host. Return the new domain in the locale
|
||||
|
Loading…
Reference in New Issue
Block a user