From 09ce307bdb8567b500f31f731f3070232daf7eb7 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Mon, 25 Sep 2017 16:53:55 +0100 Subject: [PATCH] Disable libIDN2 underscore workaround with libIDN or fixed libIDN2. --- src/util.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util.c b/src/util.c index 76ee7f4..fdc7ed6 100644 --- a/src/util.c +++ b/src/util.c @@ -200,18 +200,20 @@ char *canonicalise(char *in, int *nomem) if (!(rc = check_name(in))) return NULL; -#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2) - /* libidn2 strips underscores, so don't do IDN processing +#if defined(HAVE_LIBIDN2) && (!defined(IDN2_VERSION_NUMBER) || IDN2_VERSION_NUMBER < 0x02000003) + /* older libidn2 strips underscores, so don't do IDN processing if the name has an underscore (check_name() returned 2) */ if (rc != 2) +#endif +#if defined(HAVE_IDN) || defined(HAVE_LIBIDN2) { -#ifdef HAVE_LIBIDN2 +# ifdef HAVE_LIBIDN2 rc = idn2_to_ascii_lz(in, &ret, IDN2_NONTRANSITIONAL); if (rc == IDN2_DISALLOWED) rc = idn2_to_ascii_lz(in, &ret, IDN2_TRANSITIONAL); -#else +# else rc = idna_to_ascii_lz(in, &ret, 0); -#endif +# endif if (rc != IDNA_SUCCESS) { if (ret)