]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add idna test for UseSTD3ASCIIRules=true
authorOndřej Surý <ondrej@sury.org>
Wed, 6 Oct 2021 17:19:33 +0000 (19:19 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 12 Oct 2021 10:11:52 +0000 (12:11 +0200)
Add test to encode unicode sequence that encodes differently with
UseSTD3ASCIIRules=false which is default with idn2 >= 2.0.3 and
UseSTD3ASCIIRules=true which is what should be used to encode hostnames
and domains.

bin/tests/system/idna/tests.sh

index 6b91dd67691aa4ac60e36024f6c95c956b432c88..5cb1c41a677426711fa03c0efafd0f3a80fb4f03 100644 (file)
@@ -90,7 +90,7 @@ qname() {
 #        parameter should have that period as well.
 
 idna_test() {
-    n=`expr $n + 1`
+    n=$((n+1))
     description=$1
     if [ "$2" != "" ]; then
         description="${description}: $2"
@@ -109,7 +109,7 @@ idna_test() {
             ret=1
         fi
     fi
-    status=`expr $status + $ret`
+    status=$((status+ret))
 }
 
 # Function for performing a test where "dig" is expected to fail
@@ -119,7 +119,7 @@ idna_test() {
 #   $3 - Name being queried
 
 idna_fail() {
-    n=`expr $n + 1`
+    n=$((n+1))
     description=$1
     if [ "$2" != "" ]; then
         description="${description}: $2"
@@ -132,7 +132,7 @@ idna_fail() {
         echo_i "failed: dig command unexpectedly succeeded"
         ret=1
     fi
-    status=`expr $status + $ret`
+    status=$((status+ret))
 }
 
 # Function to check that case is preserved for an all-ASCII label.
@@ -306,9 +306,6 @@ idna_enabled_test() {
     idna_fail "$text" "+idnin   +noidnout" "$label"
     idna_fail "$text" "+idnin     +idnout" "$label"
 
-
-
-
     # Tests of a valid unicode string but an invalid U-label (input)
     #
     # Symbols are not valid IDNA2008 names.  Check whether dig rejects them
@@ -350,6 +347,29 @@ idna_enabled_test() {
     idna_test "$text" "+noidnin +noidnout" "xn--19g" "xn--19g."
     idna_fail "$text" "+noidnin +idnout"   "xn--19g"
     idna_fail "$text" "+idnin   +idnout"   "xn--19g"
+
+    # Test that the UseSTD3ASCIIRules is being used
+    #
+    # Note that "+noidnin +idnout" is not tested because libidn2 2.2.0+ parses
+    # Punycode more strictly than older versions and thus dig succeeds with that
+    # combination of options with libidn2 2.2.0+ but fails with older
+    # versions.
+    #
+    # Note that "+idnin +idnout" is not tested because libidn2 2.2.0+ parses
+    # Punycode more strictly than older versions and thus dig fails with that
+    # combination of options with libidn2 2.2.0+ but succeeds with older
+    # versions.
+    #
+    # With UseSTD13ASCIIRules=false, '☺' produces 'xn--\032o-oia59s'
+    #
+    # With UseSTD13ASCIIRules=true, '☺' produces 'xn--o-vfa'
+
+    text="Check that UseSTD3ASCIIRules is being used"
+    idna_test "$text" ""                   "☺" "\195\162\203\156\194\186."
+    idna_test "$text" "+noidnin +noidnout" "☺" "\195\162\203\156\194\186."
+    # idna_test "$text" "+noidnin +idnout"   "☺" "xn--o-vfa."
+    idna_test "$text" "+idnin   +noidnout" "☺" "xn--o-vfa."
+    # idna_fail "$text" "+idnin   +idnout"   "☺" "âo."
 }