dovecot-2.2: lib-imap: Added IMAP_PARSE_FLAG_STOP_AT_LIST for st...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 2 21:30:00 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/0c4ee3b9fa3b
changeset: 16915:0c4ee3b9fa3b
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 02 20:09:28 2013 +0200
description:
lib-imap: Added IMAP_PARSE_FLAG_STOP_AT_LIST for stopping after '('
diffstat:
src/lib-imap/imap-parser.c | 10 ++++++++--
src/lib-imap/imap-parser.h | 4 +++-
2 files changed, 11 insertions(+), 3 deletions(-)
diffs (48 lines):
diff -r 09d5728a69d1 -r 0c4ee3b9fa3b src/lib-imap/imap-parser.c
--- a/src/lib-imap/imap-parser.c Sat Nov 02 20:05:08 2013 +0200
+++ b/src/lib-imap/imap-parser.c Sat Nov 02 20:09:28 2013 +0200
@@ -609,6 +609,10 @@
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 @@
/* 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 @@
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;
diff -r 09d5728a69d1 -r 0c4ee3b9fa3b src/lib-imap/imap-parser.h
--- a/src/lib-imap/imap-parser.h Sat Nov 02 20:05:08 2013 +0200
+++ b/src/lib-imap/imap-parser.h Sat Nov 02 20:09:28 2013 +0200
@@ -24,7 +24,9 @@
/* 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;
More information about the dovecot-cvs
mailing list