changeset 20260:9b5fddcd1f68

lib-imap-storage: Allow HEADER.FIELDS(..) without space before '(' This is to allow doveadm fetch to use it. Attempting to do this without a space in IMAP already fails elsewhere: x fetch 1 body.peek[header.fields(from to)] x BAD Error in IMAP command FETCH: Invalid characters in atom
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 03 May 2016 19:39:44 +0300
parents 161d6407e613
children 3edc9022b42f
files src/lib-imap-storage/imap-msgpart.c
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap-storage/imap-msgpart.c	Tue May 03 14:58:37 2016 +0300
+++ b/src/lib-imap-storage/imap-msgpart.c	Tue May 03 19:39:44 2016 +0300
@@ -184,6 +184,9 @@
 {
 	ARRAY_TYPE(const_string) fields;
 
+	if (header_list[0] == ' ')
+		header_list++;
+
 	/* HEADER.FIELDS (list), HEADER.FIELDS.NOT (list) */
 	if (imap_msgpart_get_header_fields(msgpart->pool, header_list,
 					   &fields) < 0)
@@ -267,14 +270,14 @@
 		if (section[6] == '\0') {
 			msgpart->fetch_type = FETCH_HEADER;
 			ret = 0;
-		} else if (strncmp(section, "HEADER.FIELDS ", 14) == 0) {
+		} else if (strncmp(section, "HEADER.FIELDS.NOT", 17) == 0) {
+			msgpart->fetch_type = FETCH_HEADER_FIELDS_NOT;
+			ret = imap_msgpart_parse_header_fields(msgpart,
+							       section+17);
+		} else if (strncmp(section, "HEADER.FIELDS", 13) == 0) {
 			msgpart->fetch_type = FETCH_HEADER_FIELDS;
 			ret = imap_msgpart_parse_header_fields(msgpart,
-							       section+14);
-		} else if (strncmp(section, "HEADER.FIELDS.NOT ", 18) == 0) {
-			msgpart->fetch_type = FETCH_HEADER_FIELDS_NOT;
-			ret = imap_msgpart_parse_header_fields(msgpart,
-							       section+18);
+							       section+13);
 		} else {
 			ret = -1;
 		}