Commit 64fa378e authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 24bab517
......@@ -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},
/*
......
......@@ -438,7 +438,8 @@ enum
OPTUSEFROM,
OPTUSEGPGAGENT,
#ifdef HAVE_LIBIDN
OPTUSEIDN,
OPTIDNDECODE,
OPTIDNENCODE,
#endif
#ifdef HAVE_GETADDRINFO
OPTUSEIPV6,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment