dovecot-2.2: imap: FETCH BODY[n] shouldn't include MIME headers

dovecot at dovecot.org dovecot at dovecot.org
Sat Aug 11 04:09:55 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/5ceeb25ed337
changeset: 14853:5ceeb25ed337
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Aug 11 04:09:41 2012 +0300
description:
imap: FETCH BODY[n] shouldn't include MIME headers

diffstat:

 src/lib-imap-storage/imap-msgpart.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r 04abd58abf7a -r 5ceeb25ed337 src/lib-imap-storage/imap-msgpart.c
--- 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;


More information about the dovecot-cvs mailing list