]> granicus.if.org Git - mutt/commitdiff
Fix IDN API incompatibility problems.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 12 Nov 2003 13:49:32 +0000 (13:49 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 12 Nov 2003 13:49:32 +0000 (13:49 +0000)
configure.in
mutt_idna.c
mutt_idna.h
mutt_socket.c

index 6a4214a1c883a1b5f531939096011b8f49dcbfc5..892f2f608bab80f8eee7b7083d81fb5726df6be8 100644 (file)
@@ -685,7 +685,12 @@ AC_ARG_WITH(idn, [  --with-idn=[PFX]               Use GNU libidn for domain names],
                 ]
 )
 
-AC_CHECK_LIB(idn, idna_to_ascii_from_utf8)
+if test "x$with_idn" != "xno"; then
+   AC_CHECK_LIB(idn, stringprep_check_version)
+   AC_CHECK_FUNCS(idna_to_unicode_utf8_from_utf8 idna_to_unicode_8z8z)
+   AC_CHECK_FUNCS(idna_to_ascii_from_utf8 idna_to_ascii_8z)
+   AC_CHECK_FUNCS(idna_to_ascii_lz idna_to_ascii_from_locale)
+fi
 
 if test "$need_md5" = "yes"
 then
index 6c0cc24c638cd97ef507c67581ba23706e512ffe..9a3fbb465cd9b7bae84710d1903945eab1908064 100644 (file)
@@ -47,7 +47,7 @@ int mutt_idna_to_local (const char *in, char **out, int flags)
     goto notrans;
   
   /* Is this the right function?  Interesting effects with some bad identifiers! */
-  if (idna_to_unicode_utf8_from_utf8 (in, out, 1, 0) != IDNA_SUCCESS)
+  if (idna_to_unicode_8z8z (in, out, 1) != IDNA_SUCCESS)
     goto notrans;
   if (mutt_convert_string (out, "utf-8", Charset, M_ICONV_HOOK_TO) == -1)
     goto notrans;
@@ -63,7 +63,7 @@ int mutt_idna_to_local (const char *in, char **out, int flags)
     char *tmp = safe_strdup (*out);
     if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
       irrev = 1;
-    if (!irrev && idna_to_ascii_from_utf8 (tmp, &t2, 1, 0) != IDNA_SUCCESS)
+    if (!irrev && idna_to_ascii_8z (tmp, &t2, 1) != IDNA_SUCCESS)
       irrev = 1;
     if (!irrev && ascii_strcasecmp (t2, in))
     {
@@ -101,7 +101,7 @@ int mutt_local_to_idna (const char *in, char **out)
   
   if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
     rv = -1;
-  if (!rv && idna_to_ascii_from_utf8 (tmp, out, 1, 0) != IDNA_SUCCESS)
+  if (!rv && idna_to_ascii_8z (tmp, out, 1) != IDNA_SUCCESS)
     rv = -2;
   
   FREE (&tmp);
index 270c42097c97cb5599bcae9992c97466ab015b46..0e2534a8f9d4feaf73a455ec7c99f725870ad258 100644 (file)
@@ -40,4 +40,18 @@ int mutt_env_to_idna (ENVELOPE *, char **, char **);
 
 const char *mutt_addr_for_display (ADDRESS *a);
 
+/* Work around incompatibilities in the libidn API */
+
+#ifdef HAVE_LIBIDN
+# 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_ASCII_LZ) && defined(HAVE_IDNA_TO_ASCII_FROM_LOCALE))
+#  define idna_to_ascii_lz(a,b,c) idna_to_ascii_from_locale(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
+
 #endif
index b860192f17e9b3d0bac5c3374bbe0261330bd4d4..50ee94d520fba57e1d35e369485991938e5414b0 100644 (file)
@@ -26,9 +26,7 @@
 # include "mutt_ssl.h"
 #endif
 
-#ifdef HAVE_LIBIDN
-#include <idna.h>
-#endif
+#include "mutt_idna.h"
 
 #include <unistd.h>
 #include <netinet/in.h>
@@ -413,7 +411,7 @@ int raw_socket_open (CONNECTION* conn)
   snprintf (port, sizeof (port), "%d", conn->account.port);
   
 # ifdef HAVE_LIBIDN
-  if (idna_to_ascii_from_locale (conn->account.host, &host_idna, 1, 0) != IDNA_SUCCESS)
+  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
   {
     mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
     return -1;
@@ -470,7 +468,7 @@ int raw_socket_open (CONNECTION* conn)
   sin.sin_family = AF_INET;
 
 # ifdef HAVE_LIBIDN
-  if (idna_to_ascii_from_locale (conn->account.host, &host_idna, 1, 0) != IDNA_SUCCESS)
+  if (idna_to_ascii_lz (conn->account.host, &host_idna, 1) != IDNA_SUCCESS)
   {
     mutt_error (_("Bad IDN \"%s\"."), conn->account.host);
     return -1;