]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Message decoder now runs normalizer also for unknown charsets.
authorTimo Sirainen <tss@iki.fi>
Thu, 11 Sep 2014 13:40:00 +0000 (16:40 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 11 Sep 2014 13:40:00 +0000 (16:40 +0300)
src/lib-mail/message-decoder.c

index 9099a1a46329778bff03a4d57407cfa56afecc59..8742cc454275fe157f74497909ce07b7bb42482f 100644 (file)
@@ -334,7 +334,9 @@ static bool message_decode_body(struct message_decoder_context *ctx,
        if (ctx->binary_input) {
                output->data = data;
                output->size = size;
-       } else if (ctx->charset_utf8) {
+       } else if (ctx->charset_utf8 || ctx->charset_trans == NULL) {
+               /* handle unknown charsets the same as UTF-8. it might find
+                  usable ASCII text. */
                buffer_set_used_size(ctx->buf2, 0);
                if (ctx->normalizer != NULL) {
                        (void)ctx->normalizer(data, size, ctx->buf2);
@@ -347,16 +349,6 @@ static bool message_decode_body(struct message_decoder_context *ctx,
                        output->data = ctx->buf2->data;
                        output->size = ctx->buf2->used;
                }
-       } else if (ctx->charset_trans == NULL) {
-               /* unknown charset */
-               buffer_set_used_size(ctx->buf2, 0);
-               if (uni_utf8_get_valid_data(data, size, ctx->buf2)) {
-                       output->data = data;
-                       output->size = size;
-               } else {
-                       output->data = ctx->buf2->data;
-                       output->size = ctx->buf2->used;
-               }
        } else {
                buffer_set_used_size(ctx->buf2, 0);
                if (ctx->translation_size != 0)