From: chris mikkelson Date: Mon, 15 Mar 2010 01:48:19 +0000 (-0500) Subject: Updated boundary regexp and regexp quoting to accomodate some X-Git-Url: https://git.mikk.net/?a=commitdiff_plain;h=e73d482e3153753e46e109146b69dc94d83dc2da;p=liburl Updated boundary regexp and regexp quoting to accomodate some non-standard MIME boundary characters seen in the wild. --- diff --git a/message.c b/message.c index e6b4c2d..e90f2a9 100644 --- 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); } diff --git a/multipart.c b/multipart.c index 47d02a0..de300e4 100644 --- a/multipart.c +++ b/multipart.c @@ -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 */