]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check libidn2 version before proceding with one of the tests.
authorStephen Morris <stephen@isc.org>
Tue, 3 Apr 2018 19:02:35 +0000 (20:02 +0100)
committerStephen Morris <stephen@isc.org>
Wed, 4 Apr 2018 13:42:08 +0000 (09:42 -0400)
A known issue in libidn2 causes one of the tests of a fake A-label
to fail.  The problem should be corrected in version 2.0.5 of
libidn2.

bin/tests/system/idna/tests.sh

index 19a086dff2debdfb5fd31d82965de81411b23b8b..3a9b91b4422ef0d6af62a933782505c646482cfa 100644 (file)
@@ -136,6 +136,46 @@ idna_fail() {
     status=`expr $status + $ret`
 }
 
+# Check if current version of libidn2 is >= a given version
+#
+# This requires that:
+# a) "pkg-config" exists on the system
+# b) The libidn2 installed has an associated ".pc" file
+# c) The system sort command supports "-V"
+#
+# $1 - Minimum version required
+#
+# Returns:
+# 0 - Version check is OK, libidn2 at required version or greater.
+# 1 - Version check was made, but libidn2 not at required version.
+# 2 - Could not carry out version check
+
+libidn_version_check() {
+    ret=2
+    if [ -n "`command -v pkg-config`" ]; then
+        version=`pkg-config --modversion --silence-errors libidn2`
+        if [ -n "$version" ]; then
+            # Does the sort command have a "-V" flag on this system?
+            sort -V 2>&1 > /dev/null << .
+.
+            if [ $? -eq 0 ]; then
+                # Sort -V exists.  Sort the IDN version and the minimum version
+                # required.  If the IDN version is greater than or equal to that
+                # version, it will appear last in the list.
+                last_version=`printf "%s\n" $version $1 | sort -V | tail -1`
+                if [ "$version" = "$last_version" ]; then
+                    ret=0
+                else
+                    ret=1
+                fi
+            fi
+        fi
+    fi
+
+    return $ret
+}
+
+
 # Function to check that case is preserved for an all-ASCII label.
 #
 # Without IDNA support, case-preservation is the expected behavior.
@@ -270,10 +310,16 @@ idna_enabled_test() {
     text="Checking fake A-label"
     idna_fail "$text" ""                   "xn--ahahah"
     idna_test "$text" "+noidnin +noidnout" "xn--ahahah" "xn--ahahah."
-#   The next test is commented out as libidn2 gives invalid output for the
-#   invalid punycode name.  Until this is fixed, the test will be skipped.
-#   idna_test "$text" "+noidnin   +idnout" "xn--ahahah" "xn--ahahah."
-    echo_i "(fake A-label: +noidnin +idnout test skipped due to libidn2 issues)"
+
+    # Owing to issues with libdns, the next test will fail for versions of
+    # libidn earlier than 2.0.5.  For this reason, get the version (if
+    # available) and compare with 2.0.5.
+    libidn_version_check 2.0.5
+    if [ $? -ne 0 ]; then
+        echo_i "Skipping fake A-label +noidnin +idnout test (libidn2 version issues)"
+    else
+        idna_test "$text" "+noidnin   +idnout" "xn--ahahah" "xn--ahahah."
+    fi
     idna_fail "$text" "+idnin   +noidnout" "xn--ahahah"
     idna_fail "$text" "+idnin     +idnout" "xn--ahahah"