dovecot-2.2: lib-imap: Fixed NIL astring to not lose its case-se...

dovecot at dovecot.org dovecot at dovecot.org
Sat Nov 2 22:42:43 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/1d7e2cee2c4b
changeset: 16920:1d7e2cee2c4b
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Nov 02 22:42:32 2013 +0200
description:
lib-imap: Fixed NIL astring to not lose its case-sensitivity.

diffstat:

 src/lib-imap/imap-arg.c    |  10 +++-------
 src/lib-imap/imap-parser.c |   8 +++++---
 2 files changed, 8 insertions(+), 10 deletions(-)

diffs (43 lines):

diff -r 720c7d01ad8a -r 1d7e2cee2c4b src/lib-imap/imap-arg.c
--- 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;
diff -r 720c7d01ad8a -r 1d7e2cee2c4b src/lib-imap/imap-parser.c
--- 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. */


More information about the dovecot-cvs mailing list