From: Timo Sirainen Date: Wed, 23 Jun 2010 13:59:49 +0000 (+0100) Subject: lib-storage: When getting decoded headers, don't fail when MIME encoded-words expand... X-Git-Tag: 2.0.rc1~99 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9a664472557182cff0825a2285b8fca39f72947;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: When getting decoded headers, don't fail when MIME encoded-words expand to LFs. This fixes errors like: Corrupted index cache file dovecot.index.cache: Broken header Subject for mail UID 1 --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-mail-headers.c b/src/lib-storage/index/index-mail-headers.c index f6147c9459..21d0f33352 100644 --- a/src/lib-storage/index/index-mail-headers.c +++ b/src/lib-storage/index/index-mail-headers.c @@ -722,13 +722,14 @@ index_mail_headers_decode(struct index_mail *mail, const char *const **_list, for (i = 0; i < count; i++) { str_truncate(str, 0); input = list[i]; - if (message_header_decode_utf8((const unsigned char *)input, - strlen(list[i]), str, FALSE)) - input = str_c(str); + /* unfold all lines into a single line */ if (unfold_header(mail->data_pool, &input) < 0) return -1; - if (input == str->data) - input = p_strdup(mail->data_pool, input); + + /* decode MIME encoded-words. decoding may also add new LFs. */ + if (message_header_decode_utf8((const unsigned char *)input, + strlen(list[i]), str, FALSE)) + input = p_strdup(mail->data_pool, str_c(str)); decoded_list[i] = input; } *_list = decoded_list;