dns-domain: try IDN2003 rules if IDN2008 doesn't work

This follows more closely what web browsers do, and makes sure emojis in
domains work.

Fixes: #14483
This commit is contained in:
Lennart Poettering 2020-11-09 23:10:43 +01:00 committed by Yu Watanabe
parent 7d27d39aa7
commit d80e72ec60
1 changed files with 6 additions and 0 deletions

View File

@ -1291,8 +1291,14 @@ int dns_name_apply_idna(const char *name, char **ret) {
assert(name);
assert(ret);
/* First, try non-transitional mode (i.e. IDN2008 rules) */
r = sym_idn2_lookup_u8((uint8_t*) name, (uint8_t**) &t,
IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL);
if (r == IDN2_DISALLOWED) /* If that failed, because of disallowed characters, try transitional mode.
* (i.e. IDN2003 rules which supports some unicode chars IDN2008 doesn't allow). */
r = sym_idn2_lookup_u8((uint8_t*) name, (uint8_t**) &t,
IDN2_NFC_INPUT | IDN2_TRANSITIONAL);
log_debug("idn2_lookup_u8: %s → %s", name, t);
if (r == IDN2_OK) {
if (!startswith(name, "xn--")) {