]> git.mikk.net Git - liburl/commitdiff
Updated boundary regexp and regexp quoting to accomodate some
authorchris mikkelson <chris@mikk.net>
Mon, 15 Mar 2010 01:48:19 +0000 (20:48 -0500)
committerchris mikkelson <chris@mikk.net>
Mon, 15 Mar 2010 01:48:19 +0000 (20:48 -0500)
non-standard MIME boundary characters seen in the wild.

message.c
multipart.c

index e6b4c2d6e5f8893bd444a26aa6ff3f09d72ca6aa..e90f2a9a7a0df5a2e58b538a68ac6db8a9440f08 100644 (file)
--- a/message.c
+++ b/message.c
@@ -17,7 +17,7 @@ static const char *type_pat = "text/(plain|html)|(multipart)/";
 static pcre *type_re;
 static const char *enc_pat = "7bit|8bit|base64|quoted-printable";
 static pcre *enc_re;
-static const char *bound_pat = "boundary\\s*=\\s*\"?([\\da-z'()+,-./:=?_ \r\n]+)\"?";
+static const char *bound_pat = "boundary\\s*=\\s*\"?([\\da-z'()+,-./:=?_ \r\n!@\\[\\]]+)\"?";
 static pcre *bound_re;
 
 static msgproc_module *text_module = &msgproc_text,
@@ -277,10 +277,15 @@ message_process(msgproc *m, char *buf, size_t len)
 
                type = msgproc_create(enc, ms->type);
                if (ms->type->mpm_type == MSGPROC_MULTIPART) {
-                       assert(ms->boundary);
-                       msgproc_start(type);
-                       msgproc_set(type, 1, ms->boundary, strlen(ms->boundary));
-                       free(ms->boundary);
+                       if (ms->boundary) {
+                               msgproc_start(type);
+                               msgproc_set(type, 1, ms->boundary,
+                                               strlen(ms->boundary));
+                               free(ms->boundary);
+                       } else {
+                               msgproc_finish(type);
+                               if (enc != m) msgproc_finish(enc);
+                       }
                } else {
                        msgproc_start(type);
                }
index 47d02a0d3339fd0c4fbf8661cc1a2a797a33d553..de300e4c793a09f12e73846949c2fd7b57fc7e5a 100644 (file)
@@ -73,6 +73,8 @@ setboundary(msgproc *m, int type, void *data, size_t size)
                case '?':
                case '.':
                case '+':       /* pattern metacharacters allowed by RFC 1341 */
+               case '[':
+               case ']':       /* and a few observed "in the wild" */
                case '\\':
                        *s++ = '\\';
                        /* FALLTHROUGH */