d0d307
--- cyrus-imapd-2.2.6/imap/message.c.acceptinvalidfrom	2004-10-30 15:03:02.220642392 -0700
d0d307
+++ cyrus-imapd-2.2.6/imap/message.c	2004-10-30 15:06:01.838336352 -0700
d0d307
@@ -229,6 +229,8 @@
d0d307
     int reject8bit = config_getswitch(IMAPOPT_REJECT8BIT);
d0d307
     int munge8bit = config_getswitch(IMAPOPT_MUNGE8BIT);
d0d307
     int inheader = 1, blankline = 1;
d0d307
+    char is_from;
d0d307
+    static const char * from_header = "From ";
d0d307
 
d0d307
     while (size) {
d0d307
 	n = prot_read(from, buf, size > 4096 ? 4096 : size);
d0d307
@@ -294,8 +296,20 @@
d0d307
 	/* Check for valid header name */
d0d307
 	if (sawnl && buf[0] != ' ' && buf[0] != '\t') {
d0d307
 	    if (buf[0] == ':') return IMAP_MESSAGE_BADHEADER;
d0d307
-	    for (p = (unsigned char *)buf; *p != ':'; p++) {
d0d307
-		if (*p <= ' ') return IMAP_MESSAGE_BADHEADER;
d0d307
+            p = (unsigned char *) buf;
d0d307
+            if (*p == '>')
d0d307
+                p++;
d0d307
+            if (*p == from_header[0])
d0d307
+                is_from = 0;
d0d307
+            else
d0d307
+                is_from = -1;
d0d307
+            for (; *p != ':' && is_from < 5; p++) {
d0d307
+                if (is_from > 0 && *p != from_header[is_from])
d0d307
+                    is_from = -1;
d0d307
+                if (is_from >= 0)
d0d307
+                    is_from++;
d0d307
+                else
d0d307
+                    if (*p <= ' ') return IMAP_MESSAGE_BADHEADER;
d0d307
 	    }
d0d307
 	}
d0d307