From: Marco Bettini Date: Tue, 21 Feb 2023 10:03:11 +0000 (+0000) Subject: imap: imap_parser_read_next_atom() - Accept "]" in cmd-tag(s) X-Git-Tag: 2.4.0~2963 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4225e6853d881a126c96127aca74c977d3dcb5d2;p=thirdparty%2Fdovecot%2Fcore.git imap: imap_parser_read_next_atom() - Accept "]" in cmd-tag(s) despite "]" being in atom-specials, a specific exception is made for that in ASTRING-CHAR, which is used by tag --- diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c index 933dd9c502..82de03e293 100644 --- a/src/lib-imap/imap-parser.c +++ b/src/lib-imap/imap-parser.c @@ -989,9 +989,12 @@ imap_parser_read_next_atom(struct imap_parser *parser, bool parsing_tag, /* quoted-specials: */ case '"': case '\\': + return -1; /* resp-specials: */ case ']': - return -1; + if (!parsing_tag) + return -1; + break; case '+': if (parsing_tag) return -1; diff --git a/src/lib-imap/test-imap-parser.c b/src/lib-imap/test-imap-parser.c index 3ca4e34858..906e63ca78 100644 --- a/src/lib-imap/test-imap-parser.c +++ b/src/lib-imap/test-imap-parser.c @@ -110,6 +110,8 @@ static void test_imap_parser_read_tag_cmd(void) { "tag*", NULL, -1, BOTH }, { "tag\"", NULL, -1, BOTH }, { "tag\\", NULL, -1, BOTH }, + { "tag] ", "tag]", 1, TAG }, + { "tag]", NULL, -1, COMMAND}, { "tag+", NULL, -1, TAG }, { "tag+ ", "tag+", 1, COMMAND }, };