More tiny bugfixes on the mimeparser
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 9 Dec 2010 00:05:16 +0000 (01:05 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 9 Dec 2010 00:05:16 +0000 (01:05 +0100)
 - 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

index 7e4cbfb222ba3df3f447dfcd6474d6e7295caee8..56336ba6afe445421a1db9b3cb37c9a47780d7b2 100644 (file)
@@ -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,