]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: imap_parser_read_next_atom() - Accept "]" in cmd-tag(s)
authorMarco Bettini <marco.bettini@open-xchange.com>
Tue, 21 Feb 2023 10:03:11 +0000 (10:03 +0000)
committerMarco Bettini <marco.bettini@open-xchange.com>
Tue, 21 Feb 2023 11:35:13 +0000 (11:35 +0000)
despite "]" being in atom-specials, a specific exception is made
for that in ASTRING-CHAR, which is used by tag

src/lib-imap/imap-parser.c
src/lib-imap/test-imap-parser.c

index 933dd9c5024dd9882100d91913d38525cb62905f..82de03e293aaefa9d2e5fedc552bc69f18c8658e 100644 (file)
@@ -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;
index 3ca4e348584fc3a2440e014013f2b30d19707f9b..906e63ca783b4462e8a1985359fe7f9ac399919b 100644 (file)
@@ -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 },
        };