]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: Added IMAP_PARSE_FLAG_STOP_AT_LIST for stopping after '('
authorTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 18:09:28 +0000 (20:09 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 18:09:28 +0000 (20:09 +0200)
src/lib-imap/imap-parser.c
src/lib-imap/imap-parser.h

index cd43ae00b902ee0e2119cecd59ebf61703d5784c..19289abf5bafdb961f297278fa7a7f8489ab3d4d 100644 (file)
@@ -609,6 +609,10 @@ static int imap_parser_read_arg(struct imap_parser *parser)
                        break;
                case '(':
                        imap_parser_open_list(parser);
+                       if ((parser->flags & IMAP_PARSE_FLAG_STOP_AT_LIST) != 0) {
+                               i_stream_skip(parser->input, 1);
+                               return FALSE;
+                       }
                        break;
                case ')':
                        if (!imap_parser_close_list(parser))
@@ -690,7 +694,8 @@ static int imap_parser_read_arg(struct imap_parser *parser)
 /* ARG_PARSE_NONE checks that last argument isn't only partially parsed. */
 #define IS_UNFINISHED(parser) \
         ((parser)->cur_type != ARG_PARSE_NONE || \
-        (parser)->cur_list != &parser->root_list)
+        ((parser)->cur_list != &parser->root_list && \
+        ((parser)->flags & IMAP_PARSE_FLAG_STOP_AT_LIST) == 0))
 
 static int finish_line(struct imap_parser *parser, unsigned int count,
                       const struct imap_arg **args_r)
@@ -703,7 +708,8 @@ static int finish_line(struct imap_parser *parser, unsigned int count,
        parser->cur_pos = 0;
        parser->cur_resp_text = FALSE;
 
-       if (parser->list_arg != NULL && !parser->literal_size_return) {
+       if (parser->list_arg != NULL && !parser->literal_size_return &&
+           (parser->flags & IMAP_PARSE_FLAG_STOP_AT_LIST) == 0) {
                parser->error = "Missing ')'";
                *args_r = NULL;
                return -1;
index 623d3def8bf6e80d7a7fad8c7a6058a780dc7c35..d0bc9710da9e1864992f2efe88ac626dd9e8e648 100644 (file)
@@ -24,7 +24,9 @@ enum imap_parser_flags {
        /* We're parsing IMAP server replies. Parse the "text" after
           OK/NO/BAD/BYE replies as a single atom. We assume that the initial
           "*" or tag was already skipped over. */
-       IMAP_PARSE_FLAG_SERVER_TEXT     = 0x80
+       IMAP_PARSE_FLAG_SERVER_TEXT     = 0x80,
+       /* Parse until '(' and return it as an empty list */
+       IMAP_PARSE_FLAG_STOP_AT_LIST    = 0x100
 };
 
 struct imap_parser;