]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Message-decoder: Fixes to handling binary body parts.
authorTimo Sirainen <tss@iki.fi>
Mon, 25 May 2009 23:44:56 +0000 (19:44 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 25 May 2009 23:44:56 +0000 (19:44 -0400)
--HG--
branch : HEAD

src/lib-mail/message-decoder.c

index 47c3c64c154b76894b46b9b059eec0f4da7d196c..2f21ea2eb597365e8fbbcb0b399e1fdb14d73da6 100644 (file)
@@ -219,10 +219,15 @@ message_decode_body_init_charset(struct message_decoder_context *ctx,
 {
        enum charset_flags flags;
 
-       if (ctx->charset_utf8)
+       ctx->binary_input = ctx->content_charset == NULL &&
+               (ctx->flags & MESSAGE_DECODER_FLAG_RETURN_BINARY) != 0 &&
+               (part->flags & (MESSAGE_PART_FLAG_TEXT |
+                               MESSAGE_PART_FLAG_MESSAGE_RFC822)) == 0;
+
+       if (ctx->charset_utf8 || ctx->binary_input)
                return;
 
-       if (ctx->charset_trans != NULL &&
+       if (ctx->charset_trans != NULL && ctx->content_charset != NULL &&
            strcasecmp(ctx->content_charset, ctx->charset_trans_charset) == 0) {
                /* already have the correct translation selected */
                return;
@@ -232,13 +237,6 @@ message_decode_body_init_charset(struct message_decoder_context *ctx,
                charset_to_utf8_end(&ctx->charset_trans);
        i_free_and_null(ctx->charset_trans_charset);
 
-       ctx->binary_input = ctx->content_charset == NULL &&
-               (ctx->flags & MESSAGE_DECODER_FLAG_RETURN_BINARY) != 0 &&
-               (part->flags & (MESSAGE_PART_FLAG_TEXT |
-                               MESSAGE_PART_FLAG_MESSAGE_RFC822)) == 0;
-       if (ctx->binary_input)
-               return;
-
        flags = (ctx->flags & MESSAGE_DECODER_FLAG_DTCASE) != 0 ?
                CHARSET_FLAG_DECOMP_TITLECASE : 0;
        ctx->charset_trans_charset = i_strdup(ctx->content_charset != NULL ?