],
[with_idn=auto])
+AC_ARG_WITH(idn2, AS_HELP_STRING([--with-idn2=@<:@PFX@:>@],[Use GNU libidn2 for internationalized domain names]),
+ [
+ if test "$with_idn2" != "no" ; then
+ if test "$with_idn" = "auto"; then
+ with_idn="no"
+ fi
+
+ if test "$with_idn" != "no"; then
+ AC_MSG_ERROR([Cannot enable IDN and IDN2 support at the same time])
+ fi
+
+ if test "$with_idn2" != "yes" ; then
+ CPPFLAGS="$CPPFLAGS -I$with_idn2/include"
+ LDFLAGS="$LDFLAGS -L$with_idn2/lib"
+ fi
+ fi
+ ],
+ [with_idn2=no])
+
if test "x$with_idn" != "xno"; then
if test "$am_cv_func_iconv" != "yes"; then
if test "$with_idn" != "auto"; then
fi
fi
+dnl idna2
+if test "x$with_idn2" != "xno"; then
+ if test "$am_cv_func_iconv" != "yes"; then
+ if test "$with_idn2" != "auto"; then
+ AC_MSG_ERROR([IDN2 requested but iconv is disabled or unavailable])
+ fi
+ else
+ dnl Solaris 11 has /usr/include/idn
+ have_idn2_h=no
+ AC_CHECK_HEADERS([idn2.h idn/idn2.h], [
+ have_idn2_h=yes
+ break])
+
+ mutt_save_LIBS="$LIBS"
+ LIBS=
+
+ AC_SEARCH_LIBS([idn2_check_version], [idn2], [
+ AC_DEFINE([HAVE_LIBIDN2], 1, [Define to 1 if you have the GNU idn2 library])
+ MUTTLIBS="$MUTTLIBS $LIBS"
+
+ LIBS="$LIBS $LIBICONV"
+ AC_DEFINE([HAVE_IDNA_TO_UNICODE_8Z8Z])
+ AC_DEFINE([HAVE_IDNA_TO_ASCII_8Z])
+ AC_DEFINE([HAVE_IDNA_TO_ASCII_LZ])
+ ])
+
+ LIBS="$mutt_save_LIBS"
+
+ if test "$with_idn2" != "no"; then
+ if test "$have_idn2_h" = "no" || test "$ac_cv_search_idn2_check_version" = "no"; then
+ AC_MSG_ERROR([IDN2 was requested, but libidn2 was not usable on this system])
+ fi
+ fi
+ fi
+fi
+
dnl -- locales --
AC_CHECK_HEADERS(wchar.h)
# ifndef HAVE_LIBIDN
# define HAVE_LIBIDN
# endif
+# ifndef HAVE_LIBIDN2
+# define HAVE_LIBIDN2
+# endif
# ifndef HAVE_GETADDRINFO
# define HAVE_GETADDRINFO
# endif
** .pp
** Also see $$use_domain and $$hidden_host.
*/
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
{ "idn_decode", DT_BOOL, R_MENU, OPTIDNDECODE, 1},
/*
** .pp
** IDN. Unset this if your SMTP server can handle newer (RFC 6531)
** UTF-8 encoded domains. (IDN only)
*/
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
{ "ignore_linear_white_space", DT_BOOL, R_NONE, OPTIGNORELWS, 0 },
/*
** .pp
STRINGPREP_VERSION);
#endif
+#ifdef HAVE_LIBIDN2
+ printf ("\nlibidn2: %s (compiled with %s)", idn2_check_version (NULL),
+ IDN2_VERSION);
+#endif
+
#ifdef USE_HCACHE
printf ("\nhcache backend: %s", mutt_hcache_backend ());
#endif
#else
"-HAVE_LIBIDN "
#endif
-
+
+#if HAVE_LIBIDN2
+ "+HAVE_LIBIDN2 "
+#else
+ "-HAVE_LIBIDN2 "
+#endif
+
#if HAVE_GETSID
"+HAVE_GETSID "
#else
OPTUSEDOMAIN,
OPTUSEFROM,
OPTUSEGPGAGENT,
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
OPTIDNDECODE,
OPTIDNENCODE,
#endif
#include "charset.h"
#include "mutt_idna.h"
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
static int check_idn (char *domain)
{
if (! domain)
return 0;
}
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
static int mbox_to_udomain (const char *mbx, char **user, char **domain)
{
char *local_user = NULL, *local_domain = NULL, *mailbox = NULL;
char *reversed_user = NULL, *reversed_domain = NULL;
char *tmp = NULL;
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
int is_idn_encoded = 0;
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
local_user = safe_strdup (orig_user);
local_domain = safe_strdup (orig_domain);
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
is_idn_encoded = check_idn (local_domain);
if (is_idn_encoded && option (OPTIDNDECODE))
{
mutt_str_replace (&local_domain, tmp);
FREE (&tmp);
}
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
/* we don't want charset-hook effects, so we set flags to 0 */
if (mutt_convert_string (&local_user, "utf-8", Charset, 0) == -1)
goto cleanup;
}
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
/* If the original domain was UTF-8, idna encoding here could
* produce a non-matching domain! Thus we only want to do the
* idna_to_ascii_8z() if the original domain was IDNA encoded.
}
mutt_str_replace (&reversed_domain, tmp);
}
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
if (ascii_strcasecmp (orig_domain, reversed_domain))
{
if (mutt_convert_string (&intl_domain, Charset, "utf-8", 0) == -1)
goto cleanup;
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
if (option (OPTIDNENCODE))
{
if (idna_to_ascii_8z (intl_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
goto cleanup;
mutt_str_replace (&intl_domain, tmp);
}
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
mailbox = safe_malloc (mutt_strlen (intl_user) + mutt_strlen (intl_domain) + 2);
sprintf (mailbox, "%s@%s", NONULL(intl_user), NONULL(intl_domain)); /* __SPRINTF_CHECKED__ */
#include <idna.h>
#elif defined(HAVE_IDN_IDNA_H)
#include <idn/idna.h>
+#elif defined(HAVE_IDN2_H)
+#include <idn2.h>
+#elif defined(HAVE_IDN_IDN2_H)
+#include <idn/idn2.h>
#endif
#define MI_MAY_BE_IRREVERSIBLE (1 << 0)
/* Work around incompatibilities in the libidn API */
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
# if (!defined(HAVE_IDNA_TO_ASCII_8Z) && defined(HAVE_IDNA_TO_ASCII_FROM_UTF8))
# define idna_to_ascii_8z(a,b,c) idna_to_ascii_from_utf8(a,b,(c)&1,((c)&2)?1:0)
# endif
# if (!defined(HAVE_IDNA_TO_UNICODE_8Z8Z) && defined(HAVE_IDNA_TO_UNICODE_UTF8_FROM_UTF8))
# define idna_to_unicode_8z8z(a,b,c) idna_to_unicode_utf8_from_utf8(a,b,(c)&1,((c)&2)?1:0)
# endif
-#endif /* HAVE_LIBIDN */
+#endif /* defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) */
#ifdef HAVE_ICONV
snprintf (port, sizeof (port), "%d", conn->account.port);
-# ifdef HAVE_LIBIDN
+# if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
{
mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
rc = getaddrinfo (host_idna, port, &hints, &res);
-# ifdef HAVE_LIBIDN
+# if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
FREE (&host_idna);
# endif
sin.sin_port = htons (conn->account.port);
sin.sin_family = AF_INET;
-# ifdef HAVE_LIBIDN
+# if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
{
mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
he = gethostbyname (host_idna);
-# ifdef HAVE_LIBIDN
+# if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
FREE (&host_idna);
# endif
/* Check if 'hostname' matches the one of the subjectAltName extensions of
* type DNS or the Common Name (CN). */
-#ifdef HAVE_LIBIDN
+#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2)
if (idna_to_ascii_lz(hostname, &hostname_ascii, 0) != IDNA_SUCCESS)
{
hostname_ascii = safe_strdup(hostname);