From: Stephen Morris Date: Tue, 3 Apr 2018 19:02:35 +0000 (+0100) Subject: Check libidn2 version before proceding with one of the tests. X-Git-Tag: v9.13.0~77^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e0e81288cde88f04bc8996b98fe421f7365a8a2f;p=thirdparty%2Fbind9.git Check libidn2 version before proceding with one of the tests. 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. --- diff --git a/bin/tests/system/idna/tests.sh b/bin/tests/system/idna/tests.sh index 19a086dff2d..3a9b91b4422 100644 --- a/bin/tests/system/idna/tests.sh +++ b/bin/tests/system/idna/tests.sh @@ -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"