Skip to content

Commit

Permalink
lib-imap-storage: Allow HEADER.FIELDS(..) without space before '('
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sirainen authored and GitLab committed May 7, 2016
1 parent 2d7da70 commit 6c1b371
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib-imap-storage/imap-msgpart.c
Expand Up @@ -184,6 +184,9 @@ imap_msgpart_parse_header_fields(struct imap_msgpart *msgpart,
{
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)
Expand Down Expand Up @@ -267,14 +270,14 @@ int imap_msgpart_parse(const char *section, struct imap_msgpart **msgpart_r)
if (section[6] == '\0') {
msgpart->fetch_type = FETCH_HEADER;
ret = 0;
} else if (strncmp(section, "HEADER.FIELDS ", 14) == 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) {
} else if (strncmp(section, "HEADER.FIELDS.NOT", 17) == 0) {
msgpart->fetch_type = FETCH_HEADER_FIELDS_NOT;
ret = imap_msgpart_parse_header_fields(msgpart,
section+18);
section+17);
} else if (strncmp(section, "HEADER.FIELDS", 13) == 0) {
msgpart->fetch_type = FETCH_HEADER_FIELDS;
ret = imap_msgpart_parse_header_fields(msgpart,
section+13);
} else {
ret = -1;
}
Expand Down

0 comments on commit 6c1b371

Please sign in to comment.