]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Allow fallback to IDNA2003 processing
authorOndřej Surý <ondrej@isc.org>
Fri, 26 Aug 2022 10:24:07 +0000 (12:24 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 5 Sep 2022 08:21:28 +0000 (10:21 +0200)
In several cases where IDNA2008 mappings do not exist whereas IDNA2003
mappings do, dig was failing to process the suplied domain name.  Take a
backwards compatible approach, and convert the domain to IDNA2008 form,
and if that fails try the IDNA2003 conversion.

(cherry picked from commit 10923f9d8725c8d776b591f90a5f7e82dbae6752)

bin/dig/dighost.c

index 2131aa18ffa80aba2712bfcec9ceb172e6592cc5..1ff13b25581f54c2686e55b8909e4ad202c1ad31 100644 (file)
@@ -4817,6 +4817,9 @@ idn_locale_to_ace(const char *src, char *dst, size_t dstlen) {
         * valid domain name.
         */
        res = idn2_to_ascii_lz(src, &ascii_src, IDN2_NONTRANSITIONAL);
+       if (res == IDN2_DISALLOWED) {
+               res = idn2_to_ascii_lz(src, &ascii_src, IDN2_TRANSITIONAL);
+       }
        if (res != IDN2_OK) {
                fatal("'%s' is not a legal IDNA2008 name (%s), use +noidnin",
                      src, idn2_strerror(res));
@@ -4878,9 +4881,13 @@ idn_ace_to_locale(const char *src, char **dst) {
        }
 
        /*
-        * Then, check whether decoded 'src' is a valid IDNA2008 name.
+        * Then, check whether decoded 'src' is a valid IDNA2008 name
+        * and if disallowed character is found, fallback to IDNA2003.
         */
        res = idn2_to_ascii_8z(utf8_src, NULL, IDN2_NONTRANSITIONAL);
+       if (res == IDN2_DISALLOWED) {
+               res = idn2_to_ascii_8z(utf8_src, NULL, IDN2_TRANSITIONAL);
+       }
        if (res != IDN2_OK) {
                fatal("'%s' is not a legal IDNA2008 name (%s), use +noidnout",
                      src, idn2_strerror(res));