Mercurial > dovecot > core-2.2
diff src/lib-imap-storage/imap-msgpart.c @ 14853:5ceeb25ed337
imap: FETCH BODY[n] shouldn't include MIME headers
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 11 Aug 2012 04:09:41 +0300 |
parents | 2ab4aa784474 |
children | f3ef88e19cd5 |
line wrap: on
line diff
--- a/src/lib-imap-storage/imap-msgpart.c Sat Aug 11 03:14:43 2012 +0300 +++ b/src/lib-imap-storage/imap-msgpart.c Sat Aug 11 04:09:41 2012 +0300 @@ -15,6 +15,7 @@ enum fetch_type { FETCH_FULL, FETCH_MIME, + FETCH_MIME_BODY, FETCH_HEADER, FETCH_HEADER_FIELDS, FETCH_HEADER_FIELDS_NOT, @@ -230,10 +231,13 @@ if (*section == '\0') { /* full message/MIME part */ - msgpart->fetch_type = FETCH_FULL; msgpart->wanted_fields |= MAIL_FETCH_STREAM_BODY; - if (*msgpart->section_number == '\0') + if (*msgpart->section_number == '\0') { + msgpart->fetch_type = FETCH_FULL; msgpart->wanted_fields |= MAIL_FETCH_STREAM_HEADER; + } else { + msgpart->fetch_type = FETCH_MIME_BODY; + } return 0; } section = t_str_ucase(section); @@ -242,11 +246,11 @@ msgpart->fetch_type = FETCH_MIME; msgpart->wanted_fields |= MAIL_FETCH_STREAM_BODY; } else if (strcmp(section, "TEXT") == 0) { - /* message body */ + /* body (for root or for message/rfc822) */ msgpart->fetch_type = FETCH_BODY; msgpart->wanted_fields |= MAIL_FETCH_STREAM_BODY; } else if (strncmp(section, "HEADER", 6) == 0) { - /* header */ + /* header (for root or for message/rfc822) */ if (section[6] == '\0') { msgpart->fetch_type = FETCH_HEADER; ret = 0; @@ -272,6 +276,8 @@ msgpart->wanted_fields |= MAIL_FETCH_STREAM_HEADER; else msgpart->wanted_fields |= MAIL_FETCH_STREAM_BODY; + } else { + i_unreached(); } return 0; } @@ -529,6 +535,7 @@ result_r->size_field = MAIL_FETCH_VIRTUAL_SIZE; break; case FETCH_MIME: + case FETCH_MIME_BODY: i_unreached(); case FETCH_HEADER: case FETCH_HEADER_FIELDS_NOT: @@ -577,6 +584,7 @@ case FETCH_HEADER_FIELDS_NOT: i_unreached(); case FETCH_BODY: + case FETCH_MIME_BODY: i_stream_skip(input, hdr_size.physical_size); part_size.physical_size += body_size.physical_size; part_size.virtual_size += body_size.virtual_size;