changeset 16920:1d7e2cee2c4b

lib-imap: Fixed NIL astring to not lose its case-sensitivity.
author Timo Sirainen <tss@iki.fi>
date Sat, 02 Nov 2013 22:42:32 +0200
parents 720c7d01ad8a
children 1e75d6c90c4a
files src/lib-imap/imap-arg.c src/lib-imap/imap-parser.c
diffstat 2 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/imap-arg.c	Sat Nov 02 22:32:23 2013 +0200
+++ b/src/lib-imap/imap-arg.c	Sat Nov 02 22:42:32 2013 +0200
@@ -32,13 +32,9 @@
 
 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;
--- a/src/lib-imap/imap-parser.c	Sat Nov 02 22:32:23 2013 +0200
+++ b/src/lib-imap/imap-parser.c	Sat Nov 02 22:42:32 2013 +0200
@@ -234,14 +234,16 @@
 	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. */