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. -- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA http://www.8t8.us/configs/gpg-key-transition-statement.txt
# HG changeset patch # User Kevin McCarthy <[email protected]> # Date 1447713405 28800 # Mon Nov 16 14:36:45 2015 -0800 # Node ID 5e172867c5f9256a11ca308ed728d79c032e86de # Parent 856595362743ef7919e0bb57cce1ba50adfe1b16 Add option 'idn_encode'; rename option 'use_idn' to 'idn_decode'. 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. diff --git a/init.h b/init.h --- a/init.h +++ b/init.h @@ -1069,16 +1069,32 @@ ** domain, these are used to construct $$hostname. If there is no ** domain part returned, Mutt will look for a ``domain'' or ``search'' ** line in \fC/etc/resolv.conf\fP to determine the domain. Optionally, Mutt ** can be compiled with a fixed domain name in which case a detected ** one is not used. ** .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 ** This option replaces linear-white-space between encoded-word ** and text to a single space to prevent the display of MIME-encoded ** ``Subject:'' field from being divided into multiple lines. */ { "ignore_list_reply_to", DT_BOOL, R_NONE, OPTIGNORELISTREPLYTO, 0 }, @@ -3404,25 +3420,16 @@ { "use_from", DT_BOOL, R_NONE, OPTUSEFROM, 1 }, /* ** .pp ** When \fIset\fP, Mutt will generate the ``From:'' header field when ** sending messages. If \fIunset\fP, no ``From:'' header field will be ** 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}, /* ** .pp ** When \fIset\fP, Mutt will look for IPv6 addresses of hosts it tries to ** contact. If this option is \fIunset\fP, Mutt will restrict itself to IPv4 addresses. ** Normally, the default should work. */ diff --git a/mutt.h b/mutt.h --- a/mutt.h +++ b/mutt.h @@ -433,17 +433,18 @@ OPTTILDE, OPTTSENABLED, OPTUNCOLLAPSEJUMP, OPTUSE8BITMIME, OPTUSEDOMAIN, OPTUSEFROM, OPTUSEGPGAGENT, #ifdef HAVE_LIBIDN - OPTUSEIDN, + OPTIDNDECODE, + OPTIDNENCODE, #endif #ifdef HAVE_GETADDRINFO OPTUSEIPV6, #endif OPTWAITKEY, OPTWEED, OPTWRAP, OPTWRAPSEARCH, diff --git a/mutt_idna.c b/mutt_idna.c --- a/mutt_idna.c +++ b/mutt_idna.c @@ -99,17 +99,17 @@ #endif /* HAVE_LIBIDN */ if (mbox_to_udomain (a->mailbox, &user, &domain) == -1) goto cleanup; orig_domain = safe_strdup (domain); #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; mutt_str_replace (&domain, tmp); FREE (&tmp); } #endif /* HAVE_LIBIDN */ @@ -136,17 +136,17 @@ goto cleanup; } #ifdef HAVE_LIBIDN /* 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. */ - 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) { dprint (1, (debugfile, "intl_to_local: Not reversible. idna_to_ascii_8z failed for domain = '%s'.\n", reversed_domain)); goto cleanup; } @@ -186,19 +186,22 @@ /* we don't want charset-hook effects, so we set flags to 0 */ if (mutt_convert_string (&user, Charset, "utf-8", 0) == -1) goto cleanup; if (mutt_convert_string (&domain, Charset, "utf-8", 0) == -1) 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); sprintf (mailbox, "%s@%s", NONULL(user), NONULL(domain)); /* __SPRINTF_CHECKED__ */ cleanup: FREE (&user); FREE (&domain);
signature.asc
Description: PGP signature
