dovecot-2.2: imap-parser: Added IMAP_PARSE_FLAG_INSIDE_LIST flag.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jun 2 19:02:27 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/c54dd35e1c0e
changeset: 14589:c54dd35e1c0e
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Jun 02 17:15:18 2012 +0300
description:
imap-parser: Added IMAP_PARSE_FLAG_INSIDE_LIST flag.
Adds mode flag to IMAP parser which makes it assume it is inside a (...) list,
making ')' equal to EOL and '\n' an error.
diffstat:
src/lib-imap/imap-parser.c | 12 +++++++++++-
src/lib-imap/imap-parser.h | 4 +++-
2 files changed, 14 insertions(+), 2 deletions(-)
diffs (50 lines):
diff -r 2d9b13930a6a -r c54dd35e1c0e src/lib-imap/imap-parser.c
--- a/src/lib-imap/imap-parser.c Sat Jun 02 17:12:06 2012 +0300
+++ b/src/lib-imap/imap-parser.c Sat Jun 02 17:15:18 2012 +0300
@@ -171,6 +171,11 @@
if (parser->list_arg == NULL) {
/* we're not inside list */
+ if ((parser->flags & IMAP_PARSE_FLAG_INSIDE_LIST) != 0) {
+ parser->eol = TRUE;
+ parser->cur_type = ARG_PARSE_NONE;
+ return TRUE;
+ }
parser->error = "Unexpected ')'";
return FALSE;
}
@@ -289,7 +294,8 @@
imap_parser_save_arg(parser, data, i);
break;
} else if (data[i] == ')') {
- if (parser->list_arg != NULL) {
+ if (parser->list_arg != NULL ||
+ (parser->flags & IMAP_PARSE_FLAG_INSIDE_LIST) != 0) {
imap_parser_save_arg(parser, data, i);
break;
} else if ((parser->flags &
@@ -498,6 +504,10 @@
/* fall through */
case '\n':
/* unexpected end of line */
+ if ((parser->flags & IMAP_PARSE_FLAG_INSIDE_LIST) != 0) {
+ parser->error = "Missing ')'";
+ return FALSE;
+ }
parser->eol = TRUE;
return FALSE;
case '"':
diff -r 2d9b13930a6a -r c54dd35e1c0e src/lib-imap/imap-parser.h
--- a/src/lib-imap/imap-parser.h Sat Jun 02 17:12:06 2012 +0300
+++ b/src/lib-imap/imap-parser.h Sat Jun 02 17:15:18 2012 +0300
@@ -16,7 +16,9 @@
/* Don't check if atom contains invalid characters */
IMAP_PARSE_FLAG_ATOM_ALLCHARS = 0x08,
/* Allow strings to contain CRLFs */
- IMAP_PARSE_FLAG_MULTILINE_STR = 0x10
+ IMAP_PARSE_FLAG_MULTILINE_STR = 0x10,
+ /* Parse in list context; ')' parses as EOL */
+ IMAP_PARSE_FLAG_INSIDE_LIST = 0x20
};
struct imap_parser;
More information about the dovecot-cvs
mailing list