]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap-storage: Fixed fetching partial headers for message/rfc822 part
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 18:46:46 +0000 (21:46 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 18:46:46 +0000 (21:46 +0300)
Again broken by 333602c40.

src/lib-imap-storage/imap-msgpart.c

index aa1698231ce9063c143456bdb9cf0d5d110f9e00..0e8428ccb815d37d086ee4704a66783c4f301ed3 100644 (file)
@@ -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) {