From: Pierre Habouzit Date: Sun, 3 Dec 2006 15:12:53 +0000 (+0100) Subject: small rewrite. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=13ad0e21ee797ddff613aa47a448fb1b5915bf0c;p=apps%2Fmadmutt.git small rewrite. fix the 'extra space' bug in headers :] Signed-off-by: Pierre Habouzit --- diff --git a/copy.c b/copy.c index bf080fd..55dd192 100644 --- a/copy.c +++ b/copy.c @@ -826,85 +826,42 @@ static void format_address_header (char **h, address_t * a) m_strcat(*h, buflen, "\n"); } -static int address_header_decode (char **h) +static int address_header_decode(char **h) { - char *s = *h; - int l; + address_t *a; + char *p, *s = *h; - address_t *a = NULL; + p = strchr(s, ':'); + if (!p) + return 0; - switch (tolower ((unsigned char) *s)) { - case 'r': - { - if (ascii_strncasecmp (s, "return-path:", 12) == 0) { - l = 12; - break; - } - else if (ascii_strncasecmp (s, "reply-to:", 9) == 0) { - l = 9; + switch (mime_which_token(s, p - s)) { + case MIME_RETURN_PATH: + case MIME_REPLY_TO: + case MIME_FROM: + case MIME_CC: + case MIME_BCC: + case MIME_SENDER: + case MIME_TO: + case MIME_MAIL_FOLLOWUP_TO: + p++; break; - } - return 0; - } - case 'f': - { - if (ascii_strncasecmp (s, "from:", 5)) - return 0; - l = 5; - break; - } - case 'c': - { - if (ascii_strncasecmp (s, "cc:", 3)) - return 0; - l = 3; - break; - } - case 'b': - { - if (ascii_strncasecmp (s, "bcc:", 4)) - return 0; - l = 4; - break; - } - case 's': - { - if (ascii_strncasecmp (s, "sender:", 7)) - return 0; - l = 7; - break; - } - case 't': - { - if (ascii_strncasecmp (s, "to:", 3)) - return 0; - l = 3; - break; - } - case 'm': - { - if (ascii_strncasecmp (s, "mail-followup-to:", 17)) + default: return 0; - l = 17; - break; } - default: - return 0; - } - if ((a = rfc822_parse_adrlist (a, s + l)) == NULL) - return 0; - - mutt_addrlist_to_local (a); - rfc2047_decode_adrlist (a); - - *h = p_dupstr(s, l + 1); + a = rfc822_parse_adrlist(a, p); + if (!a) + return 0; - format_address_header (h, a); + mutt_addrlist_to_local(a); + rfc2047_decode_adrlist(a); - address_list_wipe(&a); + *h = p_dupstr(s, p - s); + format_address_header(h, a); + address_list_wipe(&a); - p_delete(&s); - return 1; + p_delete(&s); + return 1; }