]> granicus.if.org Git - neomutt/commitdiff
Add option 'idn_encode'; rename option 'use_idn' to 'idn_decode'.
authorKevin McCarthy <kevin@8t8.us>
Tue, 24 Nov 2015 23:49:28 +0000 (15:49 -0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 24 Nov 2015 23:49:28 +0000 (15:49 -0800)
This is patch 3 of 4 implementing support for SMTPUTF8 (RFC 6531).

Add an option to control whether international domains are encoded with
IDN or not.  This defaults to set, for backward compatibility.

Rename the use_idn option to idn_decode, since that more properly
reflects its purpose.

init.h
mutt.h
mutt_idna.c

diff --git a/init.h b/init.h
index 60686033d4bc2a06ddb311ee7cb27c58cd0bf91f..8f5aac5dde00a2ce5327c82d86022d0029b3d7fe 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1074,6 +1074,22 @@ struct option_t MuttVars[] = {
   ** .pp
   ** Also see $$use_domain and $$hidden_host.
   */
+#ifdef HAVE_LIBIDN
+  { "idn_decode",      DT_BOOL, R_BOTH, OPTIDNDECODE, 1},
+  /*
+  ** .pp
+  ** When \fIset\fP, Mutt will show you international domain names decoded.
+  ** Note: You can use IDNs for addresses even if this is \fIunset\fP.
+  ** This variable only affects decoding. (IDN only)
+  */
+  { "idn_encode",      DT_BOOL, R_BOTH, OPTIDNENCODE, 1},
+  /*
+  ** .pp
+  ** When \fIset\fP, Mutt will encode international domain names using
+  ** IDN.  Unset this if your SMTP server can handle newer (RFC 6531)
+  ** UTF-8 encoded domains. (IDN only)
+  */
+#endif /* HAVE_LIBIDN */
   { "ignore_linear_white_space",    DT_BOOL, R_NONE, OPTIGNORELWS, 0 },
   /*
   ** .pp
@@ -3409,15 +3425,6 @@ struct option_t MuttVars[] = {
   ** generated unless the user explicitly sets one using the ``$my_hdr''
   ** command.
   */
-#ifdef HAVE_LIBIDN
-  { "use_idn",         DT_BOOL, R_BOTH, OPTUSEIDN, 1},
-  /*
-  ** .pp
-  ** When \fIset\fP, Mutt will show you international domain names decoded.
-  ** Note: You can use IDNs for addresses even if this is \fIunset\fP.
-  ** This variable only affects decoding.
-  */
-#endif /* HAVE_LIBIDN */
 #ifdef HAVE_GETADDRINFO
   { "use_ipv6",                DT_BOOL, R_NONE, OPTUSEIPV6, 1},
   /*
diff --git a/mutt.h b/mutt.h
index 19d2680456100149ae15592a58a5baf0c77fa759..20c0e408992596a69febdd62570fd5ff3a0ae481 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -438,7 +438,8 @@ enum
   OPTUSEFROM,
   OPTUSEGPGAGENT,
 #ifdef HAVE_LIBIDN
-  OPTUSEIDN,
+  OPTIDNDECODE,
+  OPTIDNENCODE,
 #endif
 #ifdef HAVE_GETADDRINFO
   OPTUSEIPV6,
index 04a7c4caad5e4c5b21c9dc8b9b1b1b9ca602518d..03b1dd828061d2b987767054d6f2b7dde179bb5e 100644 (file)
@@ -104,7 +104,7 @@ static char *intl_to_local (ADDRESS *a, int flags)
 
 #ifdef HAVE_LIBIDN
   is_idn_encoded = check_idn (domain);
-  if (is_idn_encoded && option (OPTUSEIDN))
+  if (is_idn_encoded && option (OPTIDNDECODE))
   {
     if (idna_to_unicode_8z8z (domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
       goto cleanup;
@@ -141,7 +141,7 @@ static char *intl_to_local (ADDRESS *a, int flags)
      * produce a non-matching domain!  Thus we only want to do the
      * idna_to_ascii_8z() if the original domain was IDNA encoded.
      */
-    if (is_idn_encoded && option (OPTUSEIDN))
+    if (is_idn_encoded && option (OPTIDNDECODE))
     {
       if (idna_to_ascii_8z (reversed_domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
       {
@@ -191,9 +191,12 @@ static char *local_to_intl (ADDRESS *a)
     goto cleanup;
 
 #ifdef HAVE_LIBIDN
-  if (idna_to_ascii_8z (domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
-    goto cleanup;
-  mutt_str_replace (&domain, tmp);
+  if (option (OPTIDNENCODE))
+  {
+    if (idna_to_ascii_8z (domain, &tmp, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
+      goto cleanup;
+    mutt_str_replace (&domain, tmp);
+  }
 #endif /* HAVE_LIBIDN */
 
   mailbox = safe_malloc (mutt_strlen (user) + mutt_strlen (domain) + 2);