Andreas Krennmair:
[apps/madmutt.git] / parse.c
diff --git a/parse.c b/parse.c
index 84adc1a..bb1ab2a 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -23,6 +23,7 @@
 #include "rfc2047.h"
 #include "rfc2231.h"
 #include "mutt_crypt.h"
+#include "url.h"
 
 #include <string.h>
 #include <ctype.h>
@@ -1064,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':
@@ -1313,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)
   {
@@ -1356,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);