diff --git a/.travis.yml b/.travis.yml index 63e27dc..ab05552 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ compiler: - clang - gcc before_install: - - sudo apt-get install -qq autotools-dev libidn11-dev + - sudo apt-get install -qq autotools-dev libidn11-dev libidn2-0-dev before_script: - ./autogen.sh script: ./configure && make V=1 && make check V=1 diff --git a/configure.ac b/configure.ac index 56b3832..2361fc5 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,17 @@ AC_ARG_WITH([libidn-headers], [CFLAGS="$CFLAGS -I$with_libidn_headers"], []) +AC_ARG_WITH([libidn2], + [AS_HELP_STRING([--with-libidn2], [Support IDN (needs GNU libidn2) @<:@check@:>@])], + [with_libidn2="$withval"], + [with_libidn2="check"]) +AS_IF([test x"$with_libidn2" != xno], + [AC_SEARCH_LIBS([idn2_check_version], [idn2], + [AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 is available.])], + [AS_IF([test x"$with_idn2" = xcheck], + [AC_MSG_WARN([Unable to find libidn2.])], + [AC_MSG_ERROR([--with-libidn2 was given but libidn2 was not found.])])])]) + AC_CHECK_LIB([resolv], [res_mkquery], [], [ AC_MSG_CHECKING([if res_mkquery is provided by libresolv with mangled symbols]) save_LIBS="$LIBS" diff --git a/src/lib/hesiod.c b/src/lib/hesiod.c index 2738713..5173a59 100644 --- a/src/lib/hesiod.c +++ b/src/lib/hesiod.c @@ -74,6 +74,9 @@ static const char rcsid[] = "$Id: hesiod.c,v 1.30 2002-04-03 21:40:55 ghudson Ex #include #include #endif +#ifdef HAVE_LIBIDN2 +#include +#endif #include "hesiod.h" /* A few operating systems don't define this. */ @@ -246,6 +249,15 @@ char *hesiod_to_bind(void *context, const char *name, const char *type) } ret = strdup(idn_ret); idn_free(idn_ret); +#elif HAVE_LIBIDN2 + rc = idn2_to_ascii_lz(bindname, &idn_ret, 0); + if (rc != IDN2_OK) + { + errno = EINVAL; + return NULL; + } + ret = strdup(idn_ret); + idn2_free(idn_ret); #else ret = strdup(bindname); #endif