]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: NIL as astring is the same as "NIL"
authorTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 20:30:42 +0000 (22:30 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 2 Nov 2013 20:30:42 +0000 (22:30 +0200)
This is a bit klugdy but works as long as all callers use
imap_arg_get_astring() instead of trying to handle it themselves.

src/lib-imap/imap-arg.c
src/lib-imap/imap-arg.h

index f44498901adb64288b4467139f19c69b372a85bb..8ca37fc764f11b2a5029482a4f73b5589c4d95e9 100644 (file)
@@ -32,6 +32,12 @@ 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))
                return FALSE;
 
index fb9df81060db061ab58392608a878ec31cc8d9dc..870d4ccf82790ec7225008c283424b2ad149205e 100644 (file)
@@ -60,7 +60,9 @@ struct imap_arg {
        unsigned int literal8:1; /* BINARY literal8 used */
 };
 
-/* RFC 3501's astring type */
+/* RFC 3501's astring type. Note that this doesn't return TRUE for
+   IMAP_ARG_NIL, although it should be treated the same as "NIL" string when
+   reading an astring. */
 #define IMAP_ARG_TYPE_IS_ASTRING(type) \
        ((type) == IMAP_ARG_ATOM || \
         (type) == IMAP_ARG_STRING || \