diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-11-09 23:10:43 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-12-10 17:36:42 +0100 |
commit | 3ed0113438f2854a8f08d30727d0ea47bb254ec4 (patch) | |
tree | 894626c9162aefcc19bfa25b876307ffd65c449c | |
parent | 663f36c6cf63a55d14626d3bfdb7dca31ca74726 (diff) | |
download | systemd-3ed0113438f2854a8f08d30727d0ea47bb254ec4.tar.gz |
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
(cherry picked from commit d80e72ec602c2af2983842ad87e4443fce89d423)
(cherry picked from commit 6790521b595c036a190e628be85199b5e4241273)
-rw-r--r-- | src/shared/dns-domain.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index b812665315..8912194352 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -1274,8 +1274,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 = 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 = 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--")) { |