]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Ignore Content-* headers if there's no MIME-Version header. Note that this
authorTimo Sirainen <tss@iki.fi>
Sun, 13 Jul 2003 01:08:10 +0000 (04:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 13 Jul 2003 01:08:10 +0000 (04:08 +0300)
change breaks cached message parts in indexes.

--HG--
branch : HEAD

src/lib-imap/imap-bodystructure.c
src/lib-mail/message-parser.c
src/lib-mail/message-parser.h

index 639f2815060f2a63517db37812144cd60d636de3..f40dd289bf0598eb4bcab0384a0de55963cecd38 100644 (file)
@@ -260,7 +260,8 @@ static void parse_header(struct message_part *part,
 
        t_push();
 
-       parse_content_header(part_data, hdr, pool);
+       if ((part->flags & MESSAGE_PART_FLAG_IS_MIME) != 0)
+               parse_content_header(part_data, hdr, pool);
 
        if (parent_rfc822) {
                /* message/rfc822, we need the envelope */
index cf571691683c36e15046cf1c157b7b16bf542c3e..f02260dc5b948686d6eb174f3eb8bfcad227b2cd 100644 (file)
@@ -166,6 +166,8 @@ message_parse_multipart(struct istream *input,
        while (next_part == parent_part) {
                /* new child */
                part = message_part_append(parser_ctx->pool, parent_part);
+               if ((parent_part->flags & MESSAGE_PART_FLAG_IS_MIME) != 0)
+                       part->flags |= MESSAGE_PART_FLAG_IS_MIME;
 
                 parser_ctx->part = part;
                next_part = message_parse_part(input, parser_ctx);
@@ -216,6 +218,11 @@ message_parse_part(struct istream *input, struct parser_context *parser_ctx)
                                             parser_ctx->context);
                }
 
+               if (!hdr->eoh && strcasecmp(hdr->name, "Mime-Version") == 0) {
+                       /* it's MIME. Content-* headers are valid */
+                       parser_ctx->part->flags |= MESSAGE_PART_FLAG_IS_MIME;
+               }
+
                if (!hdr->eoh && strcasecmp(hdr->name, "Content-Type") == 0) {
                        if (hdr->continues) {
                                hdr->use_full_value = TRUE;
@@ -229,6 +236,14 @@ message_parse_part(struct istream *input, struct parser_context *parser_ctx)
                                                     parser_ctx);
                }
        }
+
+       if ((parser_ctx->part->flags & MESSAGE_PART_FLAG_IS_MIME) == 0) {
+               /* It's not MIME. Reset everything we found from
+                  Content-Type. */
+               parser_ctx->part->flags = 0;
+                parser_ctx->last_boundary = NULL;
+               parser_ctx->last_content_type = NULL;
+       }
        if (parser_ctx->callback != NULL) {
                parser_ctx->callback(parser_ctx->part, NULL,
                                     parser_ctx->context);
index 3ccfa9becb23db6679c8f3d2fabf2ceb7927032f..e44f3042b97f99fd6add4652d9e9cc4a7818ae72 100644 (file)
@@ -18,7 +18,10 @@ enum message_part_flags {
        MESSAGE_PART_FLAG_BINARY                = 0x10,
 
        /* message part header or body contains NULs */
-       MESSAGE_PART_FLAG_HAS_NULS              = 0x20
+       MESSAGE_PART_FLAG_HAS_NULS              = 0x20,
+
+       /* Mime-Version header exists. */
+       MESSAGE_PART_FLAG_IS_MIME               = 0x40
 };
 
 struct message_part {