X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=parse.c;h=6a076540807c683bcfc9944b6df2279e17c4ae72;hp=84adc1a165f88dc519d38d215af7924870d52efa;hb=b661011c5210796beaf103676c0d24b87f1a2787;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/parse.c b/parse.c index 84adc1a..6a07654 100644 --- a/parse.c +++ b/parse.c @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mutt_regex.h" #include "mailbox.h" @@ -23,6 +27,7 @@ #include "rfc2047.h" #include "rfc2231.h" #include "mutt_crypt.h" +#include "url.h" #include #include @@ -208,9 +213,23 @@ static PARAMETER *parse_parameters (const char *s) if (*s == '"') { + int state_ascii = 1; s++; - for (i=0; *s && *s != '"' && i < sizeof (buffer) - 1; i++, s++) + for (i=0; *s && i < sizeof (buffer) - 1; i++, s++) { + if (!option (OPTSTRICTMIME)) { + /* As iso-2022-* has a characer of '"' with non-ascii state, + * ignore it. */ + if (*s == 0x1b && i < sizeof (buffer) - 2) + { + if (s[1] == '(' && (s[2] == 'B' || s[2] == 'J')) + state_ascii = 1; + else + state_ascii = 0; + } + } + if (state_ascii && *s == '"') + break; if (*s == '\\') { /* Quote the next character */ @@ -379,7 +398,9 @@ void mutt_parse_content_type (char *s, BODY *ct) if (ct->type == TYPETEXT) { if (!(pc = mutt_get_parameter ("charset", ct->parameter))) - mutt_set_parameter ("charset", "us-ascii", &ct->parameter); + mutt_set_parameter ("charset", option (OPTSTRICTMIME) ? "us-ascii" : + (const char *) mutt_get_first_charset (AssumedCharset), + &ct->parameter); } } @@ -1036,6 +1057,15 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short if (!ascii_strcasecmp ("rom", line + 1)) { e->from = rfc822_parse_adrlist (e->from, p); + /* don't leave from info NULL if there's an invalid address (or + * whatever) in From: field; mutt would just display it as empty + * and mark mail/(esp.) news article as your own. aaargh! this + * bothered me for _years_ */ + if (!e->from) + { + e->from = rfc822_new_address (); + e->from->personal = safe_strdup (line+6); + } matched = 1; } #ifdef USE_NNTP @@ -1064,17 +1094,42 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short if (!ascii_strcasecmp (line + 1, "ines")) { if (hdr) + { hdr->lines = atoi (p); - /* - * HACK - mutt has, for a very short time, produced negative - * Lines header values. Ignore them. - */ - if (hdr->lines < 0) - hdr->lines = 0; + /* + * HACK - mutt has, for a very short time, produced negative + * Lines header values. Ignore them. + */ + if (hdr->lines < 0) + hdr->lines = 0; + } matched = 1; } + else if (!ascii_strcasecmp (line + 1, "ist-Post")) + { + /* RFC 2369. FIXME: We should ignore whitespace, but don't. */ + if (strncmp (p, "NO", 2)) + { + char *beg, *end; + for (beg = strchr (p, '<'); beg; beg = strchr (end, ',')) + { + ++beg; + if (!(end = strchr (beg, '>'))) + break; + + /* Take the first mailto URL */ + if (url_check_scheme (beg) == U_MAILTO) + { + FREE (&e->list_post); + e->list_post = mutt_substrdup (beg, end); + break; + } + } + } + matched = 1; + } break; case 'm': @@ -1313,6 +1368,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs, long loc; int matched; size_t linelen = LONG_STRING; + char buf[LONG_STRING+1]; if (hdr) { @@ -1356,6 +1412,49 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs, break; /* end of header */ } + *buf = '\0'; + + if (mutt_match_spam_list(line, SpamList, buf, sizeof(buf))) + { + if (!mutt_match_rx_list(line, NoSpamList)) + { + + /* if spam tag already exists, figure out how to amend it */ + if (e->spam && *buf) + { + /* If SpamSep defined, append with separator */ + if (SpamSep) + { + mutt_buffer_addstr(e->spam, SpamSep); + mutt_buffer_addstr(e->spam, buf); + } + + /* else overwrite */ + else + { + e->spam->dptr = e->spam->data; + *e->spam->dptr = '\0'; + mutt_buffer_addstr(e->spam, buf); + } + } + + /* spam tag is new, and match expr is non-empty; copy */ + else if (!e->spam && *buf) + { + e->spam = mutt_buffer_from(NULL, buf); + } + + /* match expr is empty; plug in null string if no existing tag */ + else if (!e->spam) + { + e->spam = mutt_buffer_from(NULL, ""); + } + + if (e->spam && e->spam->data) + dprint(5, (debugfile, "p822: spam = %s\n", e->spam->data)); + } + } + *p = 0; p++; SKIPWS (p); @@ -1377,6 +1476,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs, rfc2047_decode_adrlist (e->from); rfc2047_decode_adrlist (e->to); rfc2047_decode_adrlist (e->cc); + rfc2047_decode_adrlist (e->bcc); rfc2047_decode_adrlist (e->reply_to); rfc2047_decode_adrlist (e->mail_followup_to); rfc2047_decode_adrlist (e->return_path);