From 585ffccc2892fd5ca1a2aae3686b7d9199f35bd4 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Thu, 9 Dec 2010 01:05:16 +0100 Subject: [PATCH] More tiny bugfixes on the mimeparser - in the for-loop, search first start as initializer, this saves one unneccesary memcmp - cr/lf detection: we need to do that _before_ the first mime content is evaluated. --- libcitadel/lib/mime_parser.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libcitadel/lib/mime_parser.c b/libcitadel/lib/mime_parser.c index 7e4cbfb22..56336ba6a 100644 --- a/libcitadel/lib/mime_parser.c +++ b/libcitadel/lib/mime_parser.c @@ -538,8 +538,8 @@ static char *FindNextContent(char *ptr, } - next_boundary = NULL; - for (srch=ptr; + srch = next_boundary = NULL; + for (srch = memchr(ptr, '-', content_end - srch); (srch != NULL) && (srch < content_end); srch = memchr(srch, '-', content_end - srch)) { @@ -620,9 +620,15 @@ static void recurseable_mime_parser(char *partnum, ptr ++; part_start = NULL; do { + char *optr; + optr = ptr; if (parse_MimeHeaders(SubMimeHeaders, &ptr, content_end) != 0) break; + if ((ptr - optr > 2) && + (*(ptr - 2) == '\r')) + crlf_in_use = 1; + part_start = ptr; next_boundary = FindNextContent(ptr, -- 2.39.2