dovecot: If Content-Type: was the first header in a MIME part, w...

dovecot at dovecot.org dovecot at dovecot.org
Sun Nov 11 19:04:26 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/eb4f1fbeecda
changeset: 6781:eb4f1fbeecda
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Nov 11 19:04:23 2007 +0200
description:
If Content-Type: was the first header in a MIME part, we didn't set
content_type_text flag properly and so we searched non-text MIME parts
unneededly.

diffstat:

1 file changed, 24 insertions(+), 12 deletions(-)
src/lib-mail/message-search.c |   36 ++++++++++++++++++++++++------------

diffs (67 lines):

diff -r 8b11c9f06bbf -r eb4f1fbeecda src/lib-mail/message-search.c
--- a/src/lib-mail/message-search.c	Sun Nov 11 18:51:33 2007 +0200
+++ b/src/lib-mail/message-search.c	Sun Nov 11 19:04:23 2007 +0200
@@ -118,16 +118,35 @@ static bool search_header(struct message
 		 str_find_more(ctx->str_find_ctx, crlf, 2));
 }
 
+static int message_search_more_decoded2(struct message_search_context *ctx,
+					struct message_block *block)
+{
+	if (block->hdr != NULL) {
+		if (search_header(ctx, block->hdr))
+			return 1;
+	} else {
+		if (str_find_more(ctx->str_find_ctx, block->data, block->size))
+			return 1;
+	}
+	return 0;
+}
+
 int message_search_more(struct message_search_context *ctx,
 			struct message_block *raw_block)
 {
 	struct message_block block;
 
+	if (raw_block->part != ctx->prev_part) {
+		/* part changes. we must change this before looking at
+		   content type */
+		message_search_reset(ctx);
+		ctx->prev_part = raw_block->part;
+	}
+
 	if (raw_block->hdr != NULL) {
-		if (ctx->flags & MESSAGE_SEARCH_FLAG_SKIP_HEADERS)
+		handle_header(ctx, raw_block->hdr);
+		if ((ctx->flags & MESSAGE_SEARCH_FLAG_SKIP_HEADERS) != 0)
 			return 0;
-
-		handle_header(ctx, raw_block->hdr);
 	} else {
 		/* body */
 		if (!ctx->content_type_text)
@@ -136,7 +155,7 @@ int message_search_more(struct message_s
 	if (!message_decoder_decode_next_block(ctx->decoder, raw_block, &block))
 		return 0;
 
-	return message_search_more_decoded(ctx, &block);
+	return message_search_more_decoded2(ctx, &block);
 }
 
 int message_search_more_decoded(struct message_search_context *ctx,
@@ -148,14 +167,7 @@ int message_search_more_decoded(struct m
 		ctx->prev_part = block->part;
 	}
 
-	if (block->hdr != NULL) {
-		if (search_header(ctx, block->hdr))
-			return 1;
-	} else {
-		if (str_find_more(ctx->str_find_ctx, block->data, block->size))
-			return 1;
-	}
-	return 0;
+	return message_search_more_decoded2(ctx, block);
 }
 
 void message_search_reset(struct message_search_context *ctx)


More information about the dovecot-cvs mailing list