From: Timo Sirainen Date: Sat, 2 Nov 2013 20:42:32 +0000 (+0200) Subject: lib-imap: Fixed NIL astring to not lose its case-sensitivity. X-Git-Tag: 2.2.7~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1dc33c503c3de306db4b7cba4e51ea2077b2805d;p=thirdparty%2Fdovecot%2Fcore.git lib-imap: Fixed NIL astring to not lose its case-sensitivity. --- diff --git a/src/lib-imap/imap-arg.c b/src/lib-imap/imap-arg.c index 8ca37fc764..902ba2ccef 100644 --- a/src/lib-imap/imap-arg.c +++ b/src/lib-imap/imap-arg.c @@ -32,13 +32,9 @@ bool imap_arg_get_string(const struct imap_arg *arg, const char **str_r) bool imap_arg_get_astring(const struct imap_arg *arg, const char **str_r) { - if (arg->type == IMAP_ARG_NIL) { - /* RFC 3501 4.5. specifies that NIL is the same as "NIL" when - reading astring. */ - *str_r = "NIL"; - return TRUE; - } - if (!IMAP_ARG_IS_ASTRING(arg)) + /* RFC 3501 4.5. specifies that NIL is the same as "NIL" when + reading astring. */ + if (!IMAP_ARG_IS_ASTRING(arg) && arg->type != IMAP_ARG_NIL) return FALSE; *str_r = arg->_data.str; diff --git a/src/lib-imap/imap-parser.c b/src/lib-imap/imap-parser.c index 19289abf5b..76740075b7 100644 --- a/src/lib-imap/imap-parser.c +++ b/src/lib-imap/imap-parser.c @@ -234,14 +234,16 @@ static void imap_parser_save_arg(struct imap_parser *parser, case ARG_PARSE_ATOM: case ARG_PARSE_TEXT: if (size == 3 && i_memcasecmp(data, "NIL", 3) == 0) { - /* NIL argument */ + /* NIL argument. it might be an actual NIL, but if + we're reading astring, it's an atom and we can't + lose its case. */ arg->type = IMAP_ARG_NIL; } else { /* simply save the string */ arg->type = IMAP_ARG_ATOM; - arg->_data.str = imap_parser_strdup(parser, data, size); - arg->str_len = size; } + arg->_data.str = imap_parser_strdup(parser, data, size); + arg->str_len = size; break; case ARG_PARSE_STRING: /* data is quoted and may contain escapes. */