summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2015-11-24 15:49:26 -0800
committerKevin McCarthy <kevin@8t8.us>2015-11-24 15:49:26 -0800
commit0e0520faf7a96e2cc0efa49eced65adb4e5acfe6 (patch)
treee0ffd51e41bfef7c2023e83fcf3de9eed54145ec
parent0864167e8a6ba598cf919fb26c242997518f7386 (diff)
Rename idna functions and bits for smtputf8 changes.
This is patch 1 of 4 implementing support for SMTPUTF8 (RFC 6531). Change mutt_idna.c to be always compiled. Remove the stub functions in mutt_idna.h. Instead, put #ifdefs around the idna function calls. The conversion functions will be fixed up in the next patch. Rename the conversion functions to mutt_addrlist_to_intl() and mutt_env_to_intl(). Rename the ADDRESS idna status bits to "intl" status bits.
-rw-r--r--Makefile.am4
-rw-r--r--alias.c4
-rw-r--r--commands.c2
-rw-r--r--compose.c4
-rw-r--r--configure.ac1
-rw-r--r--edit.c14
-rw-r--r--init.c4
-rw-r--r--main.c2
-rw-r--r--mutt_idna.c59
-rw-r--r--mutt_idna.h37
-rw-r--r--query.c2
-rw-r--r--recvcmd.c2
-rw-r--r--rfc822.c4
-rw-r--r--rfc822.h4
-rw-r--r--send.c8
-rw-r--r--sendlib.c2
16 files changed, 65 insertions, 88 deletions
diff --git a/Makefile.am b/Makefile.am
index baff5386..a02591f8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,7 +33,7 @@ mutt_SOURCES = \
rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
score.c send.c sendlib.c signal.c sort.c \
status.c system.c thread.c charset.c history.c lib.c \
- muttlib.c editmsg.c mbyte.c \
+ muttlib.c editmsg.c mbyte.c mutt_idna.c \
url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
nodist_mutt_SOURCES = $(BUILT_SOURCES)
@@ -53,7 +53,7 @@ AM_CPPFLAGS=-I. -I$(top_srcdir) $(IMAP_INCLUDES) $(GPGME_CFLAGS) -Iintl
EXTRA_mutt_SOURCES = account.c bcache.c crypt-gpgme.c crypt-mod-pgp-classic.c \
crypt-mod-pgp-gpgme.c crypt-mod-smime-classic.c \
crypt-mod-smime-gpgme.c dotlock.c gnupgparse.c hcache.c md5.c \
- mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
+ mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \
mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
smime.c smtp.c utf8.c wcwidth.c \
diff --git a/alias.c b/alias.c
index 986f4476..cb653fd1 100644
--- a/alias.c
+++ b/alias.c
@@ -290,7 +290,7 @@ retry_name:
else
buf[0] = 0;
- mutt_addrlist_to_idna (adr, NULL);
+ mutt_addrlist_to_intl (adr, NULL);
do
{
@@ -302,7 +302,7 @@ retry_name:
if((new->addr = rfc822_parse_adrlist (new->addr, buf)) == NULL)
BEEP ();
- if (mutt_addrlist_to_idna (new->addr, &err))
+ if (mutt_addrlist_to_intl (new->addr, &err))
{
mutt_error (_("Error: '%s' is a bad IDN."), err);
mutt_sleep (2);
diff --git a/commands.c b/commands.c
index b334c7b6..51044dd9 100644
--- a/commands.c
+++ b/commands.c
@@ -294,7 +294,7 @@ void ci_bounce_message (HEADER *h, int *redraw)
adr = mutt_expand_aliases (adr);
- if (mutt_addrlist_to_idna (adr, &err) < 0)
+ if (mutt_addrlist_to_intl (adr, &err) < 0)
{
mutt_error (_("Bad IDN: '%s'"), err);
FREE (&err);
diff --git a/compose.c b/compose.c
index d53795cb..8edd2930 100644
--- a/compose.c
+++ b/compose.c
@@ -292,7 +292,7 @@ static int edit_address_list (int line, ADDRESS **addr)
return (REDRAW_FULL);
}
- if (mutt_addrlist_to_idna (*addr, &err) != 0)
+ if (mutt_addrlist_to_intl (*addr, &err) != 0)
{
mutt_error (_("Warning: '%s' is a bad IDN."), err);
mutt_refresh();
@@ -606,7 +606,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
mutt_env_to_local (msg->env);
mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
fcc, fcclen);
- if (mutt_env_to_idna (msg->env, &tag, &err))
+ if (mutt_env_to_intl (msg->env, &tag, &err))
{
mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
FREE (&err);
diff --git a/configure.ac b/configure.ac
index 1a76cd75..29473927 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1196,7 +1196,6 @@ if test "x$with_idn" != "xno"; then
AC_SEARCH_LIBS([stringprep_check_version], [idn], [
AC_DEFINE([HAVE_LIBIDN], 1, [Define to 1 if you have the GNU idn library])
- MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_idna.o"
MUTTLIBS="$MUTTLIBS $LIBS"
LIBS="$LIBS $LIBICONV"
diff --git a/edit.c b/edit.c
index d0cab09f..532e47f0 100644
--- a/edit.c
+++ b/edit.c
@@ -247,7 +247,7 @@ static void be_edit_header (ENVELOPE *e, int force)
rfc822_free_address (&e->to);
e->to = mutt_parse_adrlist (e->to, tmp);
e->to = mutt_expand_aliases (e->to);
- mutt_addrlist_to_idna (e->to, NULL); /* XXX - IDNA error reporting? */
+ mutt_addrlist_to_intl (e->to, NULL); /* XXX - IDNA error reporting? */
tmp[0] = 0;
rfc822_write_address (tmp, sizeof (tmp), e->to, 1);
mvaddstr (LINES - 1, 4, tmp);
@@ -255,7 +255,7 @@ static void be_edit_header (ENVELOPE *e, int force)
}
else
{
- mutt_addrlist_to_idna (e->to, NULL); /* XXX - IDNA error reporting? */
+ mutt_addrlist_to_intl (e->to, NULL); /* XXX - IDNA error reporting? */
addstr (tmp);
}
addch ('\n');
@@ -281,12 +281,12 @@ static void be_edit_header (ENVELOPE *e, int force)
e->cc = mutt_parse_adrlist (e->cc, tmp);
e->cc = mutt_expand_aliases (e->cc);
tmp[0] = 0;
- mutt_addrlist_to_idna (e->cc, NULL);
+ mutt_addrlist_to_intl (e->cc, NULL);
rfc822_write_address (tmp, sizeof (tmp), e->cc, 1);
mvaddstr (LINES - 1, 4, tmp);
}
else
- mutt_addrlist_to_idna (e->cc, NULL);
+ mutt_addrlist_to_intl (e->cc, NULL);
addch ('\n');
}
@@ -301,13 +301,13 @@ static void be_edit_header (ENVELOPE *e, int force)
rfc822_free_address (&e->bcc);
e->bcc = mutt_parse_adrlist (e->bcc, tmp);
e->bcc = mutt_expand_aliases (e->bcc);
- mutt_addrlist_to_idna (e->bcc, NULL);
+ mutt_addrlist_to_intl (e->bcc, NULL);
tmp[0] = 0;
rfc822_write_address (tmp, sizeof (tmp), e->bcc, 1);
mvaddstr (LINES - 1, 5, tmp);
}
else
- mutt_addrlist_to_idna (e->bcc, NULL);
+ mutt_addrlist_to_intl (e->bcc, NULL);
addch ('\n');
}
}
@@ -447,7 +447,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur)
{
mutt_env_to_local (msg->env);
mutt_edit_headers (NONULL(Visual), path, msg, NULL, 0);
- if (mutt_env_to_idna (msg->env, &tag, &err))
+ if (mutt_env_to_intl (msg->env, &tag, &err))
printw (_("Bad IDN in %s: '%s'\n"), tag, err);
}
else
diff --git a/init.c b/init.c
index 118f06f5..c5439a13 100644
--- a/init.c
+++ b/init.c
@@ -874,7 +874,7 @@ static int parse_group (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
case ADDR:
if ((addr = mutt_parse_adrlist (NULL, buf->data)) == NULL)
goto bail;
- if (mutt_addrlist_to_idna (addr, &estr))
+ if (mutt_addrlist_to_intl (addr, &estr))
{
snprintf (err->data, err->dsize, _("%sgroup: warning: bad IDN '%s'.\n"),
data == 1 ? "un" : "", estr);
@@ -1339,7 +1339,7 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
last->next = tmp;
else
Aliases = tmp;
- if (mutt_addrlist_to_idna (tmp->addr, &estr))
+ if (mutt_addrlist_to_intl (tmp->addr, &estr))
{
snprintf (err->data, err->dsize, _("Warning: Bad IDN '%s' in alias '%s'.\n"),
estr, tmp->name);
diff --git a/main.c b/main.c
index 17e8bf4c..42ac8d40 100644
--- a/main.c
+++ b/main.c
@@ -803,7 +803,7 @@ int main (int argc, char **argv)
if ((a = mutt_lookup_alias (alias_queries->data)))
{
/* output in machine-readable form */
- mutt_addrlist_to_idna (a, NULL);
+ mutt_addrlist_to_intl (a, NULL);
mutt_write_address_list (a, stdout, 0, 0);
}
else
diff --git a/mutt_idna.c b/mutt_idna.c
index f720116a..4169f788 100644
--- a/mutt_idna.c
+++ b/mutt_idna.c
@@ -24,9 +24,7 @@
#include "charset.h"
#include "mutt_idna.h"
-/* The low-level interface we use. */
-#ifdef HAVE_LIBIDN
/* check whether an address is an IDN */
@@ -37,21 +35,21 @@ static int check_idn (ADDRESS *ap)
if (!ap || !ap->mailbox)
return 0;
- if (!ap->idn_checked)
+ if (!ap->intl_checked)
{
- ap->idn_checked = 1;
+ ap->intl_checked = 1;
for (p = strchr (ap->mailbox, '@'); p && *p; p = strchr (p, '.'))
if (ascii_strncasecmp (++p, "xn--", 4) == 0)
{
- ap->is_idn = 1;
+ ap->is_intl = 1;
break;
}
}
- return ap->is_idn;
+ return ap->is_intl;
}
-static int mutt_idna_to_local (const char *in, char **out, int flags)
+static int intl_to_local (const char *in, char **out, int flags)
{
*out = NULL;
@@ -62,8 +60,10 @@ static 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! */
+#ifdef HAVE_LIBIDN
if (idna_to_unicode_8z8z (in, out, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
goto notrans;
+#endif /* HAVE_LIBIDN */
/* we don't want charset-hook effects, so we set flags to 0 */
if (mutt_convert_string (out, "utf-8", Charset, 0) == -1)
@@ -83,11 +83,13 @@ static int mutt_idna_to_local (const char *in, char **out, int flags)
/* we don't want charset-hook effects, so we set flags to 0 */
if (mutt_convert_string (&tmp, Charset, "utf-8", 0) == -1)
irrev = 1;
+#ifdef HAVE_LIBIDN
if (!irrev && idna_to_ascii_8z (tmp, &t2, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
irrev = 1;
+#endif /* HAVE_LIBIDN */
if (!irrev && ascii_strcasecmp (t2, in))
{
- dprint (1, (debugfile, "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
+ dprint (1, (debugfile, "intl_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
in, t2));
irrev = 1;
}
@@ -107,7 +109,7 @@ static int mutt_idna_to_local (const char *in, char **out, int flags)
return 1;
}
-static int mutt_local_to_idna (const char *in, char **out)
+static int local_to_intl (const char *in, char **out)
{
int rv = 0;
char *tmp = safe_strdup (in);
@@ -122,8 +124,11 @@ static int mutt_local_to_idna (const char *in, char **out)
/* we don't want charset-hook effects, so we set flags to 0 */
if (mutt_convert_string (&tmp, Charset, "utf-8", 0) == -1)
rv = -1;
+
+#ifdef HAVE_LIBIDN
if (!rv && idna_to_ascii_8z (tmp, out, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS)
rv = -2;
+#endif /* HAVE_LIBIDN */
FREE (&tmp);
if (rv < 0)
@@ -152,7 +157,7 @@ static int mbox_to_udomain (const char *mbx, char **user, char **domain)
return 0;
}
-int mutt_addrlist_to_idna (ADDRESS *a, char **err)
+int mutt_addrlist_to_intl (ADDRESS *a, char **err)
{
char *user = NULL, *domain = NULL;
char *tmp = NULL;
@@ -168,7 +173,7 @@ int mutt_addrlist_to_idna (ADDRESS *a, char **err)
if (mbox_to_udomain (a->mailbox, &user, &domain) == -1)
continue;
- if (mutt_local_to_idna (domain, &tmp) < 0)
+ if (local_to_intl (domain, &tmp) < 0)
{
e = 1;
if (err)
@@ -178,7 +183,7 @@ int mutt_addrlist_to_idna (ADDRESS *a, char **err)
{
safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL(user), NONULL(tmp)); /* __SPRINTF_CHECKED__ */
- a->idn_checked = 0;
+ a->intl_checked = 0;
}
FREE (&tmp);
@@ -203,11 +208,11 @@ int mutt_addrlist_to_local (ADDRESS *a)
continue;
if (mbox_to_udomain (a->mailbox, &user, &domain) == -1)
continue;
- if (mutt_idna_to_local (domain, &tmp, 0) == 0)
+ if (intl_to_local (domain, &tmp, 0) == 0)
{
safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
- a->idn_checked = 0;
+ a->intl_checked = 0;
}
FREE (&tmp);
@@ -232,7 +237,7 @@ const char *mutt_addr_for_display (ADDRESS *a)
return a->mailbox;
if (mbox_to_udomain (a->mailbox, &user, &domain) != 0)
return a->mailbox;
- if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0)
+ if (intl_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0)
{
FREE (&tmp);
return a->mailbox;
@@ -261,25 +266,23 @@ void mutt_env_to_local (ENVELOPE *e)
* "real" name of an `env' compound member. Real name will be substituted
* by preprocessor at the macro-expansion time.
*/
-#define H_TO_IDNA(a) \
- if (mutt_addrlist_to_idna (env->a, err) && !e) \
+#define H_TO_INTL(a) \
+ if (mutt_addrlist_to_intl (env->a, err) && !e) \
{ \
if (tag) *tag = #a; e = 1; err = NULL; \
}
-int mutt_env_to_idna (ENVELOPE *env, char **tag, char **err)
+int mutt_env_to_intl (ENVELOPE *env, char **tag, char **err)
{
int e = 0;
- H_TO_IDNA(return_path);
- H_TO_IDNA(from);
- H_TO_IDNA(to);
- H_TO_IDNA(cc);
- H_TO_IDNA(bcc);
- H_TO_IDNA(reply_to);
- H_TO_IDNA(mail_followup_to);
+ H_TO_INTL(return_path);
+ H_TO_INTL(from);
+ H_TO_INTL(to);
+ H_TO_INTL(cc);
+ H_TO_INTL(bcc);
+ H_TO_INTL(reply_to);
+ H_TO_INTL(mail_followup_to);
return e;
}
-#undef H_TO_IDNA
-
-#endif /* HAVE_LIBIDN */
+#undef H_TO_INTL
diff --git a/mutt_idna.h b/mutt_idna.h
index 1d51806a..48236a26 100644
--- a/mutt_idna.h
+++ b/mutt_idna.h
@@ -33,14 +33,6 @@
/* Work around incompatibilities in the libidn API */
#ifdef HAVE_LIBIDN
-int mutt_addrlist_to_idna (ADDRESS *, char **);
-int mutt_addrlist_to_local (ADDRESS *);
-
-void mutt_env_to_local (ENVELOPE *);
-int mutt_env_to_idna (ENVELOPE *, char **, char **);
-
-const char *mutt_addr_for_display (ADDRESS *a);
-
# 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
@@ -50,33 +42,16 @@ const char *mutt_addr_for_display (ADDRESS *a);
# 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
-#else
-
-static inline int mutt_addrlist_to_idna (ADDRESS *addr, char **err)
-{
- return 0;
-}
+#endif /* HAVE_LIBIDN */
-static inline int mutt_addrlist_to_local (ADDRESS *addr)
-{
- return 0;
-}
-static inline void mutt_env_to_local (ENVELOPE *env)
-{
- return;
-}
+int mutt_addrlist_to_intl (ADDRESS *, char **);
+int mutt_addrlist_to_local (ADDRESS *);
-static inline int mutt_env_to_idna (ENVELOPE *env, char **tag, char **err)
-{
- return 0;
-}
+void mutt_env_to_local (ENVELOPE *);
+int mutt_env_to_intl (ENVELOPE *, char **, char **);
-static inline const char *mutt_addr_for_display (ADDRESS *a)
-{
- return a->mailbox;
-}
+const char *mutt_addr_for_display (ADDRESS *a);
-#endif /* HAVE_LIBIDN */
#endif
diff --git a/query.c b/query.c
index 1a56a425..7c4e969c 100644
--- a/query.c
+++ b/query.c
@@ -66,7 +66,7 @@ static ADDRESS *result_to_addr (QUERY *r)
if(!tmp->next && !tmp->personal)
tmp->personal = safe_strdup (r->name);
- mutt_addrlist_to_idna (tmp, NULL);
+ mutt_addrlist_to_intl (tmp, NULL);
return tmp;
}
diff --git a/recvcmd.c b/recvcmd.c
index a6a3a91f..13cb3a65 100644
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -185,7 +185,7 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr,
adr = mutt_expand_aliases (adr);
- if (mutt_addrlist_to_idna (adr, &err) < 0)
+ if (mutt_addrlist_to_intl (adr, &err) < 0)
{
mutt_error (_("Bad IDN: '%s'"), err);
FREE (&err);
diff --git a/rfc822.c b/rfc822.c
index d9aad9e9..7eedfacc 100644
--- a/rfc822.c
+++ b/rfc822.c
@@ -801,8 +801,8 @@ ADDRESS *rfc822_cpy_adr_real (ADDRESS *addr)
p->personal = safe_strdup (addr->personal);
p->mailbox = safe_strdup (addr->mailbox);
p->group = addr->group;
- p->is_idn = addr->is_idn;
- p->idn_checked = addr->idn_checked;
+ p->is_intl = addr->is_intl;
+ p->intl_checked = addr->intl_checked;
return p;
}
diff --git a/rfc822.h b/rfc822.h
index 5eda0b6d..deddd97a 100644
--- a/rfc822.h
+++ b/rfc822.h
@@ -42,8 +42,8 @@ typedef struct address_t
char *mailbox; /* mailbox and host address */
int group; /* group mailbox? */
struct address_t *next;
- unsigned is_idn : 1;
- unsigned idn_checked : 1;
+ unsigned is_intl : 1;
+ unsigned intl_checked : 1;
}
ADDRESS;
diff --git a/send.c b/send.c
index d5a61fb0..c52d60d0 100644
--- a/send.c
+++ b/send.c
@@ -201,7 +201,7 @@ static int edit_address (ADDRESS **a, /* const */ char *field)
return (-1);
rfc822_free_address (a);
*a = mutt_expand_aliases (mutt_parse_adrlist (NULL, buf));
- if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0)
+ if ((idna_ok = mutt_addrlist_to_intl (*a, &err)) != 0)
{
mutt_error (_("Error: '%s' is a bad IDN."), err);
mutt_refresh ();
@@ -1423,7 +1423,7 @@ ci_send_message (int flags, /* send mode */
{
mutt_env_to_local (msg->env);
mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc));
- mutt_env_to_idna (msg->env, NULL, NULL);
+ mutt_env_to_intl (msg->env, NULL, NULL);
}
else
{
@@ -1629,7 +1629,7 @@ main_loop:
encode_descriptions (msg->content, 1);
mutt_prepare_envelope (msg->env, 0);
- mutt_env_to_idna (msg->env, NULL, NULL); /* Handle bad IDNAs the next time. */
+ mutt_env_to_intl (msg->env, NULL, NULL); /* Handle bad IDNAs the next time. */
if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur && (flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc) < 0)
{
@@ -1659,7 +1659,7 @@ main_loop:
}
}
- if (mutt_env_to_idna (msg->env, &tag, &err))
+ if (mutt_env_to_intl (msg->env, &tag, &err))
{
mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
FREE (&err);
diff --git a/sendlib.c b/sendlib.c
index a74874d1..44d4f3b6 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -2603,7 +2603,7 @@ int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to)
rfc822_qualify (from, fqdn);
rfc2047_encode_adrlist (from, "Resent-From");
- if (mutt_addrlist_to_idna (from, &err))
+ if (mutt_addrlist_to_intl (from, &err))
{
mutt_error (_("Bad IDN %s while preparing resent-from."),
err);