]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Enable IDN2_USE_STD3_ASCII_RULES to idn2 conversion functions
authorOndřej Surý <ondrej@sury.org>
Tue, 5 Oct 2021 09:35:59 +0000 (11:35 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 12 Oct 2021 10:11:52 +0000 (12:11 +0200)
libidn2 defaults to UseSTD3ASCIIRules=false. That allows arbitrary ASCII
characters to show up in the toASCII output, including space and
underscore.  Enable IDN2_USE_STD3_ASCII_RULES to the libidn2 conversion
to disallow additional characters from the conversion (see Validity
Criteria[1]).

bin/dig/dighost.c

index b4e6b75a55d72c8543183a4d8462bc3777cc3ceb..fc45fab3320cc5b7ad0b4473762d1d768d279249 100644 (file)
@@ -4365,7 +4365,9 @@ idn_locale_to_ace(const char *src, char *dst, size_t dstlen) {
         * We trust libidn2 to return an error if 'src' is too large to be a
         * valid domain name.
         */
-       res = idn2_to_ascii_lz(src, &ascii_src, IDN2_NONTRANSITIONAL);
+       res = idn2_to_ascii_lz(src, &ascii_src,
+                              IDN2_NONTRANSITIONAL |
+                                      IDN2_USE_STD3_ASCII_RULES);
        if (res != IDN2_OK) {
                fatal("'%s' is not a legal IDNA2008 name (%s), use +noidnin",
                      src, idn2_strerror(res));
@@ -4420,7 +4422,7 @@ idn_ace_to_locale(const char *src, char **dst) {
         *
         * First, convert 'src' to UTF-8, ignoring the current locale.
         */
-       res = idn2_to_unicode_8z8z(src, &utf8_src, 0);
+       res = idn2_to_unicode_8z8z(src, &utf8_src, IDN2_USE_STD3_ASCII_RULES);
        if (res != IDN2_OK) {
                fatal("Bad ACE string '%s' (%s), use +noidnout", src,
                      idn2_strerror(res));
@@ -4429,7 +4431,9 @@ idn_ace_to_locale(const char *src, char **dst) {
        /*
         * Then, check whether decoded 'src' is a valid IDNA2008 name.
         */
-       res = idn2_to_ascii_8z(utf8_src, NULL, IDN2_NONTRANSITIONAL);
+       res = idn2_to_ascii_8z(utf8_src, NULL,
+                              IDN2_NONTRANSITIONAL |
+                                      IDN2_USE_STD3_ASCII_RULES);
        if (res != IDN2_OK) {
                fatal("'%s' is not a legal IDNA2008 name (%s), use +noidnout",
                      src, idn2_strerror(res));
@@ -4439,11 +4443,13 @@ idn_ace_to_locale(const char *src, char **dst) {
         * Finally, try converting the decoded 'src' into the current locale's
         * character encoding.
         */
-       res = idn2_to_unicode_8zlz(utf8_src, &local_src, 0);
+       res = idn2_to_unicode_8zlz(utf8_src, &local_src,
+                                  IDN2_USE_STD3_ASCII_RULES);
        if (res != IDN2_OK) {
                static bool warned = false;
 
-               res = idn2_to_ascii_8z(utf8_src, &local_src, 0);
+               res = idn2_to_ascii_8z(utf8_src, &local_src,
+                                      IDN2_USE_STD3_ASCII_RULES);
                if (res != IDN2_OK) {
                        fatal("Cannot represent '%s' "
                              "in the current locale nor ascii (%s), "