mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+65 -88
+2 -2
Makefile.am
··· 33 33 rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ 34 34 score.c send.c sendlib.c signal.c sort.c \ 35 35 status.c system.c thread.c charset.c history.c lib.c \ 36 - muttlib.c editmsg.c mbyte.c \ 36 + muttlib.c editmsg.c mbyte.c mutt_idna.c \ 37 37 url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c 38 38 39 39 nodist_mutt_SOURCES = $(BUILT_SOURCES) ··· 53 53 EXTRA_mutt_SOURCES = account.c bcache.c crypt-gpgme.c crypt-mod-pgp-classic.c \ 54 54 crypt-mod-pgp-gpgme.c crypt-mod-smime-classic.c \ 55 55 crypt-mod-smime-gpgme.c dotlock.c gnupgparse.c hcache.c md5.c \ 56 - mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ 56 + mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ 57 57 mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ 58 58 pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ 59 59 smime.c smtp.c utf8.c wcwidth.c \
+2 -2
alias.c
··· 290 290 else 291 291 buf[0] = 0; 292 292 293 - mutt_addrlist_to_idna (adr, NULL); 293 + mutt_addrlist_to_intl (adr, NULL); 294 294 295 295 do 296 296 { ··· 302 302 303 303 if((new->addr = rfc822_parse_adrlist (new->addr, buf)) == NULL) 304 304 BEEP (); 305 - if (mutt_addrlist_to_idna (new->addr, &err)) 305 + if (mutt_addrlist_to_intl (new->addr, &err)) 306 306 { 307 307 mutt_error (_("Error: '%s' is a bad IDN."), err); 308 308 mutt_sleep (2);
+1 -1
commands.c
··· 294 294 295 295 adr = mutt_expand_aliases (adr); 296 296 297 - if (mutt_addrlist_to_idna (adr, &err) < 0) 297 + if (mutt_addrlist_to_intl (adr, &err) < 0) 298 298 { 299 299 mutt_error (_("Bad IDN: '%s'"), err); 300 300 FREE (&err);
+2 -2
compose.c
··· 292 292 return (REDRAW_FULL); 293 293 } 294 294 295 - if (mutt_addrlist_to_idna (*addr, &err) != 0) 295 + if (mutt_addrlist_to_intl (*addr, &err) != 0) 296 296 { 297 297 mutt_error (_("Warning: '%s' is a bad IDN."), err); 298 298 mutt_refresh(); ··· 606 606 mutt_env_to_local (msg->env); 607 607 mutt_edit_headers (NONULL (Editor), msg->content->filename, msg, 608 608 fcc, fcclen); 609 - if (mutt_env_to_idna (msg->env, &tag, &err)) 609 + if (mutt_env_to_intl (msg->env, &tag, &err)) 610 610 { 611 611 mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); 612 612 FREE (&err);
-1
configure.ac
··· 1196 1196 1197 1197 AC_SEARCH_LIBS([stringprep_check_version], [idn], [ 1198 1198 AC_DEFINE([HAVE_LIBIDN], 1, [Define to 1 if you have the GNU idn library]) 1199 - MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_idna.o" 1200 1199 MUTTLIBS="$MUTTLIBS $LIBS" 1201 1200 1202 1201 LIBS="$LIBS $LIBICONV"
+7 -7
edit.c
··· 247 247 rfc822_free_address (&e->to); 248 248 e->to = mutt_parse_adrlist (e->to, tmp); 249 249 e->to = mutt_expand_aliases (e->to); 250 - mutt_addrlist_to_idna (e->to, NULL); /* XXX - IDNA error reporting? */ 250 + mutt_addrlist_to_intl (e->to, NULL); /* XXX - IDNA error reporting? */ 251 251 tmp[0] = 0; 252 252 rfc822_write_address (tmp, sizeof (tmp), e->to, 1); 253 253 mvaddstr (LINES - 1, 4, tmp); ··· 255 255 } 256 256 else 257 257 { 258 - mutt_addrlist_to_idna (e->to, NULL); /* XXX - IDNA error reporting? */ 258 + mutt_addrlist_to_intl (e->to, NULL); /* XXX - IDNA error reporting? */ 259 259 addstr (tmp); 260 260 } 261 261 addch ('\n'); ··· 281 281 e->cc = mutt_parse_adrlist (e->cc, tmp); 282 282 e->cc = mutt_expand_aliases (e->cc); 283 283 tmp[0] = 0; 284 - mutt_addrlist_to_idna (e->cc, NULL); 284 + mutt_addrlist_to_intl (e->cc, NULL); 285 285 rfc822_write_address (tmp, sizeof (tmp), e->cc, 1); 286 286 mvaddstr (LINES - 1, 4, tmp); 287 287 } 288 288 else 289 - mutt_addrlist_to_idna (e->cc, NULL); 289 + mutt_addrlist_to_intl (e->cc, NULL); 290 290 addch ('\n'); 291 291 } 292 292 ··· 301 301 rfc822_free_address (&e->bcc); 302 302 e->bcc = mutt_parse_adrlist (e->bcc, tmp); 303 303 e->bcc = mutt_expand_aliases (e->bcc); 304 - mutt_addrlist_to_idna (e->bcc, NULL); 304 + mutt_addrlist_to_intl (e->bcc, NULL); 305 305 tmp[0] = 0; 306 306 rfc822_write_address (tmp, sizeof (tmp), e->bcc, 1); 307 307 mvaddstr (LINES - 1, 5, tmp); 308 308 } 309 309 else 310 - mutt_addrlist_to_idna (e->bcc, NULL); 310 + mutt_addrlist_to_intl (e->bcc, NULL); 311 311 addch ('\n'); 312 312 } 313 313 } ··· 447 447 { 448 448 mutt_env_to_local (msg->env); 449 449 mutt_edit_headers (NONULL(Visual), path, msg, NULL, 0); 450 - if (mutt_env_to_idna (msg->env, &tag, &err)) 450 + if (mutt_env_to_intl (msg->env, &tag, &err)) 451 451 printw (_("Bad IDN in %s: '%s'\n"), tag, err); 452 452 } 453 453 else
+2 -2
init.c
··· 874 874 case ADDR: 875 875 if ((addr = mutt_parse_adrlist (NULL, buf->data)) == NULL) 876 876 goto bail; 877 - if (mutt_addrlist_to_idna (addr, &estr)) 877 + if (mutt_addrlist_to_intl (addr, &estr)) 878 878 { 879 879 snprintf (err->data, err->dsize, _("%sgroup: warning: bad IDN '%s'.\n"), 880 880 data == 1 ? "un" : "", estr); ··· 1339 1339 last->next = tmp; 1340 1340 else 1341 1341 Aliases = tmp; 1342 - if (mutt_addrlist_to_idna (tmp->addr, &estr)) 1342 + if (mutt_addrlist_to_intl (tmp->addr, &estr)) 1343 1343 { 1344 1344 snprintf (err->data, err->dsize, _("Warning: Bad IDN '%s' in alias '%s'.\n"), 1345 1345 estr, tmp->name);
+1 -1
main.c
··· 803 803 if ((a = mutt_lookup_alias (alias_queries->data))) 804 804 { 805 805 /* output in machine-readable form */ 806 - mutt_addrlist_to_idna (a, NULL); 806 + mutt_addrlist_to_intl (a, NULL); 807 807 mutt_write_address_list (a, stdout, 0, 0); 808 808 } 809 809 else
+31 -28
mutt_idna.c
··· 24 24 #include "charset.h" 25 25 #include "mutt_idna.h" 26 26 27 - /* The low-level interface we use. */ 28 27 29 - #ifdef HAVE_LIBIDN 30 28 31 29 /* check whether an address is an IDN */ 32 30 ··· 37 35 if (!ap || !ap->mailbox) 38 36 return 0; 39 37 40 - if (!ap->idn_checked) 38 + if (!ap->intl_checked) 41 39 { 42 - ap->idn_checked = 1; 40 + ap->intl_checked = 1; 43 41 for (p = strchr (ap->mailbox, '@'); p && *p; p = strchr (p, '.')) 44 42 if (ascii_strncasecmp (++p, "xn--", 4) == 0) 45 43 { 46 - ap->is_idn = 1; 44 + ap->is_intl = 1; 47 45 break; 48 46 } 49 47 } 50 48 51 - return ap->is_idn; 49 + return ap->is_intl; 52 50 } 53 51 54 - static int mutt_idna_to_local (const char *in, char **out, int flags) 52 + static int intl_to_local (const char *in, char **out, int flags) 55 53 { 56 54 *out = NULL; 57 55 ··· 62 60 goto notrans; 63 61 64 62 /* Is this the right function? Interesting effects with some bad identifiers! */ 63 + #ifdef HAVE_LIBIDN 65 64 if (idna_to_unicode_8z8z (in, out, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS) 66 65 goto notrans; 66 + #endif /* HAVE_LIBIDN */ 67 67 68 68 /* we don't want charset-hook effects, so we set flags to 0 */ 69 69 if (mutt_convert_string (out, "utf-8", Charset, 0) == -1) ··· 83 83 /* we don't want charset-hook effects, so we set flags to 0 */ 84 84 if (mutt_convert_string (&tmp, Charset, "utf-8", 0) == -1) 85 85 irrev = 1; 86 + #ifdef HAVE_LIBIDN 86 87 if (!irrev && idna_to_ascii_8z (tmp, &t2, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS) 87 88 irrev = 1; 89 + #endif /* HAVE_LIBIDN */ 88 90 if (!irrev && ascii_strcasecmp (t2, in)) 89 91 { 90 - dprint (1, (debugfile, "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n", 92 + dprint (1, (debugfile, "intl_to_local: Not reversible. in = '%s', t2 = '%s'.\n", 91 93 in, t2)); 92 94 irrev = 1; 93 95 } ··· 107 109 return 1; 108 110 } 109 111 110 - static int mutt_local_to_idna (const char *in, char **out) 112 + static int local_to_intl (const char *in, char **out) 111 113 { 112 114 int rv = 0; 113 115 char *tmp = safe_strdup (in); ··· 122 124 /* we don't want charset-hook effects, so we set flags to 0 */ 123 125 if (mutt_convert_string (&tmp, Charset, "utf-8", 0) == -1) 124 126 rv = -1; 127 + 128 + #ifdef HAVE_LIBIDN 125 129 if (!rv && idna_to_ascii_8z (tmp, out, IDNA_ALLOW_UNASSIGNED) != IDNA_SUCCESS) 126 130 rv = -2; 131 + #endif /* HAVE_LIBIDN */ 127 132 128 133 FREE (&tmp); 129 134 if (rv < 0) ··· 152 157 return 0; 153 158 } 154 159 155 - int mutt_addrlist_to_idna (ADDRESS *a, char **err) 160 + int mutt_addrlist_to_intl (ADDRESS *a, char **err) 156 161 { 157 162 char *user = NULL, *domain = NULL; 158 163 char *tmp = NULL; ··· 168 173 if (mbox_to_udomain (a->mailbox, &user, &domain) == -1) 169 174 continue; 170 175 171 - if (mutt_local_to_idna (domain, &tmp) < 0) 176 + if (local_to_intl (domain, &tmp) < 0) 172 177 { 173 178 e = 1; 174 179 if (err) ··· 178 183 { 179 184 safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2); 180 185 sprintf (a->mailbox, "%s@%s", NONULL(user), NONULL(tmp)); /* __SPRINTF_CHECKED__ */ 181 - a->idn_checked = 0; 186 + a->intl_checked = 0; 182 187 } 183 188 184 189 FREE (&tmp); ··· 203 208 continue; 204 209 if (mbox_to_udomain (a->mailbox, &user, &domain) == -1) 205 210 continue; 206 - if (mutt_idna_to_local (domain, &tmp, 0) == 0) 211 + if (intl_to_local (domain, &tmp, 0) == 0) 207 212 { 208 213 safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2); 209 214 sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */ 210 - a->idn_checked = 0; 215 + a->intl_checked = 0; 211 216 } 212 217 213 218 FREE (&tmp); ··· 232 237 return a->mailbox; 233 238 if (mbox_to_udomain (a->mailbox, &user, &domain) != 0) 234 239 return a->mailbox; 235 - if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0) 240 + if (intl_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0) 236 241 { 237 242 FREE (&tmp); 238 243 return a->mailbox; ··· 261 266 * "real" name of an `env' compound member. Real name will be substituted 262 267 * by preprocessor at the macro-expansion time. 263 268 */ 264 - #define H_TO_IDNA(a) \ 265 - if (mutt_addrlist_to_idna (env->a, err) && !e) \ 269 + #define H_TO_INTL(a) \ 270 + if (mutt_addrlist_to_intl (env->a, err) && !e) \ 266 271 { \ 267 272 if (tag) *tag = #a; e = 1; err = NULL; \ 268 273 } 269 274 270 - int mutt_env_to_idna (ENVELOPE *env, char **tag, char **err) 275 + int mutt_env_to_intl (ENVELOPE *env, char **tag, char **err) 271 276 { 272 277 int e = 0; 273 - H_TO_IDNA(return_path); 274 - H_TO_IDNA(from); 275 - H_TO_IDNA(to); 276 - H_TO_IDNA(cc); 277 - H_TO_IDNA(bcc); 278 - H_TO_IDNA(reply_to); 279 - H_TO_IDNA(mail_followup_to); 278 + H_TO_INTL(return_path); 279 + H_TO_INTL(from); 280 + H_TO_INTL(to); 281 + H_TO_INTL(cc); 282 + H_TO_INTL(bcc); 283 + H_TO_INTL(reply_to); 284 + H_TO_INTL(mail_followup_to); 280 285 return e; 281 286 } 282 287 283 - #undef H_TO_IDNA 284 - 285 - #endif /* HAVE_LIBIDN */ 288 + #undef H_TO_INTL
+6 -31
mutt_idna.h
··· 33 33 /* Work around incompatibilities in the libidn API */ 34 34 35 35 #ifdef HAVE_LIBIDN 36 - int mutt_addrlist_to_idna (ADDRESS *, char **); 37 - int mutt_addrlist_to_local (ADDRESS *); 38 - 39 - void mutt_env_to_local (ENVELOPE *); 40 - int mutt_env_to_idna (ENVELOPE *, char **, char **); 41 - 42 - const char *mutt_addr_for_display (ADDRESS *a); 43 - 44 36 # if (!defined(HAVE_IDNA_TO_ASCII_8Z) && defined(HAVE_IDNA_TO_ASCII_FROM_UTF8)) 45 37 # define idna_to_ascii_8z(a,b,c) idna_to_ascii_from_utf8(a,b,(c)&1,((c)&2)?1:0) 46 38 # endif ··· 50 42 # if (!defined(HAVE_IDNA_TO_UNICODE_8Z8Z) && defined(HAVE_IDNA_TO_UNICODE_UTF8_FROM_UTF8)) 51 43 # define idna_to_unicode_8z8z(a,b,c) idna_to_unicode_utf8_from_utf8(a,b,(c)&1,((c)&2)?1:0) 52 44 # endif 53 - #else 45 + #endif /* HAVE_LIBIDN */ 54 46 55 - static inline int mutt_addrlist_to_idna (ADDRESS *addr, char **err) 56 - { 57 - return 0; 58 - } 59 47 60 - static inline int mutt_addrlist_to_local (ADDRESS *addr) 61 - { 62 - return 0; 63 - } 48 + int mutt_addrlist_to_intl (ADDRESS *, char **); 49 + int mutt_addrlist_to_local (ADDRESS *); 64 50 65 - static inline void mutt_env_to_local (ENVELOPE *env) 66 - { 67 - return; 68 - } 69 - 70 - static inline int mutt_env_to_idna (ENVELOPE *env, char **tag, char **err) 71 - { 72 - return 0; 73 - } 51 + void mutt_env_to_local (ENVELOPE *); 52 + int mutt_env_to_intl (ENVELOPE *, char **, char **); 74 53 75 - static inline const char *mutt_addr_for_display (ADDRESS *a) 76 - { 77 - return a->mailbox; 78 - } 54 + const char *mutt_addr_for_display (ADDRESS *a); 79 55 80 - #endif /* HAVE_LIBIDN */ 81 56 82 57 #endif
+1 -1
query.c
··· 66 66 if(!tmp->next && !tmp->personal) 67 67 tmp->personal = safe_strdup (r->name); 68 68 69 - mutt_addrlist_to_idna (tmp, NULL); 69 + mutt_addrlist_to_intl (tmp, NULL); 70 70 return tmp; 71 71 } 72 72
+1 -1
recvcmd.c
··· 185 185 186 186 adr = mutt_expand_aliases (adr); 187 187 188 - if (mutt_addrlist_to_idna (adr, &err) < 0) 188 + if (mutt_addrlist_to_intl (adr, &err) < 0) 189 189 { 190 190 mutt_error (_("Bad IDN: '%s'"), err); 191 191 FREE (&err);
+2 -2
rfc822.c
··· 801 801 p->personal = safe_strdup (addr->personal); 802 802 p->mailbox = safe_strdup (addr->mailbox); 803 803 p->group = addr->group; 804 - p->is_idn = addr->is_idn; 805 - p->idn_checked = addr->idn_checked; 804 + p->is_intl = addr->is_intl; 805 + p->intl_checked = addr->intl_checked; 806 806 return p; 807 807 } 808 808
+2 -2
rfc822.h
··· 42 42 char *mailbox; /* mailbox and host address */ 43 43 int group; /* group mailbox? */ 44 44 struct address_t *next; 45 - unsigned is_idn : 1; 46 - unsigned idn_checked : 1; 45 + unsigned is_intl : 1; 46 + unsigned intl_checked : 1; 47 47 } 48 48 ADDRESS; 49 49
+4 -4
send.c
··· 201 201 return (-1); 202 202 rfc822_free_address (a); 203 203 *a = mutt_expand_aliases (mutt_parse_adrlist (NULL, buf)); 204 - if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0) 204 + if ((idna_ok = mutt_addrlist_to_intl (*a, &err)) != 0) 205 205 { 206 206 mutt_error (_("Error: '%s' is a bad IDN."), err); 207 207 mutt_refresh (); ··· 1423 1423 { 1424 1424 mutt_env_to_local (msg->env); 1425 1425 mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc)); 1426 - mutt_env_to_idna (msg->env, NULL, NULL); 1426 + mutt_env_to_intl (msg->env, NULL, NULL); 1427 1427 } 1428 1428 else 1429 1429 { ··· 1629 1629 1630 1630 encode_descriptions (msg->content, 1); 1631 1631 mutt_prepare_envelope (msg->env, 0); 1632 - mutt_env_to_idna (msg->env, NULL, NULL); /* Handle bad IDNAs the next time. */ 1632 + mutt_env_to_intl (msg->env, NULL, NULL); /* Handle bad IDNAs the next time. */ 1633 1633 1634 1634 if (!Postponed || mutt_write_fcc (NONULL (Postponed), msg, (cur && (flags & SENDREPLY)) ? cur->env->message_id : NULL, 1, fcc) < 0) 1635 1635 { ··· 1659 1659 } 1660 1660 } 1661 1661 1662 - if (mutt_env_to_idna (msg->env, &tag, &err)) 1662 + if (mutt_env_to_intl (msg->env, &tag, &err)) 1663 1663 { 1664 1664 mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); 1665 1665 FREE (&err);
+1 -1
sendlib.c
··· 2603 2603 rfc822_qualify (from, fqdn); 2604 2604 2605 2605 rfc2047_encode_adrlist (from, "Resent-From"); 2606 - if (mutt_addrlist_to_idna (from, &err)) 2606 + if (mutt_addrlist_to_intl (from, &err)) 2607 2607 { 2608 2608 mutt_error (_("Bad IDN %s while preparing resent-from."), 2609 2609 err);