X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=parse.c;h=bb1ab2a9880599bde72917be6e570d9487d36d16;hp=686d9ed3ed029b43cac458c9a88c5b9d3a789a1e;hb=0c528da3f6976cfef3d729d9cd66bd8f265a4060;hpb=047342c2a0526885217e03d06e9b7a715f55b92f diff --git a/parse.c b/parse.c index 686d9ed..bb1ab2a 100644 --- a/parse.c +++ b/parse.c @@ -23,6 +23,7 @@ #include "rfc2047.h" #include "rfc2231.h" #include "mutt_crypt.h" +#include "url.h" #include #include @@ -84,27 +85,6 @@ static char *read_rfc822_line (FILE *f, char *line, size_t *linelen) /* not reached */ } -static LIST *mutt_add_x_face (LIST *lst, char *face) -{ - LIST *n; - - n = safe_malloc(sizeof(LIST)); - n->data = safe_strdup(face); - n->next = NULL; - - if (lst) - { - LIST *l; - - for(l = lst; l->next; l = l->next); - l->next = n; - } - else - lst = n; - - return lst; -} - LIST *mutt_parse_references (char *s, int in_reply_to) { LIST *t, *lst = NULL; @@ -1085,17 +1065,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': @@ -1258,11 +1263,6 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short e->x_label = safe_strdup(p); matched = 1; } - else if (ascii_strcasecmp (line+1, "-face") == 0) - { - e->x_face = mutt_add_x_face (e->x_face, p); - matched = 1; - } #ifdef USE_NNTP else if (!mutt_strcasecmp (line + 1, "-comment-to")) { @@ -1339,6 +1339,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) { @@ -1382,6 +1383,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);