From 21d094cf5f58da522150ec2ebc009fba96b700f4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 18 May 2016 21:46:46 +0300 Subject: [PATCH] lib-imap-storage: Fixed fetching partial headers for message/rfc822 part Again broken by 333602c40. --- src/lib-imap-storage/imap-msgpart.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib-imap-storage/imap-msgpart.c b/src/lib-imap-storage/imap-msgpart.c index aa1698231c..0e8428ccb8 100644 --- a/src/lib-imap-storage/imap-msgpart.c +++ b/src/lib-imap-storage/imap-msgpart.c @@ -375,12 +375,7 @@ imap_msgpart_get_partial_header(struct mail *mail, struct istream *mail_input, struct istream *input; bool has_nuls; - if (msgpart->fetch_type == FETCH_HEADER_FIELDS) { - /* mail_get_header_stream() already filtered out the - unwanted headers. */ - input = mail_input; - i_stream_ref(input); - } else { + if (msgpart->fetch_type != FETCH_HEADER_FIELDS) { i_assert(msgpart->fetch_type == FETCH_HEADER_FIELDS_NOT); input = i_stream_create_header_filter(mail_input, HEADER_FILTER_EXCLUDE | @@ -388,6 +383,19 @@ imap_msgpart_get_partial_header(struct mail *mail, struct istream *mail_input, hdr_fields, hdr_count, *null_header_filter_callback, (void *)NULL); + } else if (msgpart->section_number[0] != '\0') { + /* fetching partial headers for a message/rfc822 part. */ + input = i_stream_create_header_filter(mail_input, + HEADER_FILTER_INCLUDE | + HEADER_FILTER_HIDE_BODY, + hdr_fields, hdr_count, + *null_header_filter_callback, + (void *)NULL); + } else { + /* mail_get_header_stream() already filtered out the + unwanted headers. */ + input = mail_input; + i_stream_ref(input); } if (message_get_header_size(input, &hdr_size, &has_nuls) < 0) {