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.
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"