]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: Fixed NIL astring to not lose its case-sensitivity.
authorTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 20:42:32 +0000 (22:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 20:42:32 +0000 (22:42 +0200)
src/lib-imap/imap-arg.c
src/lib-imap/imap-parser.c

index 8ca37fc764f11b2a5029482a4f73b5589c4d95e9..902ba2ccef88e285fdc79ec3f9f95ea0ef6d2bdb 100644 (file)
@@ -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;
index 19289abf5bafdb961f297278fa7a7f8489ab3d4d..76740075b7f89f70b35038f490054b5730c33770 100644 (file)
@@ -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. */