From: Timo Sirainen Date: Sun, 13 Jul 2003 01:08:10 +0000 (+0300) Subject: Ignore Content-* headers if there's no MIME-Version header. Note that this X-Git-Tag: 1.1.alpha1~4488 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccc1e87e2e5d951de7703aeef2bfc90fec9f467c;p=thirdparty%2Fdovecot%2Fcore.git Ignore Content-* headers if there's no MIME-Version header. Note that this change breaks cached message parts in indexes. --HG-- branch : HEAD --- diff --git a/src/lib-imap/imap-bodystructure.c b/src/lib-imap/imap-bodystructure.c index 639f281506..f40dd289bf 100644 --- a/src/lib-imap/imap-bodystructure.c +++ b/src/lib-imap/imap-bodystructure.c @@ -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 */ diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index cf57169168..f02260dc5b 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -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); diff --git a/src/lib-mail/message-parser.h b/src/lib-mail/message-parser.h index 3ccfa9becb..e44f3042b9 100644 --- a/src/lib-mail/message-parser.h +++ b/src/lib-mail/message-parser.h @@ -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 {