From: Timo Sirainen Date: Sat, 2 Nov 2013 20:30:42 +0000 (+0200) Subject: lib-imap: NIL as astring is the same as "NIL" X-Git-Tag: 2.2.7~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4699302bd6965ee803ab34613b8840a3d8203d1;p=thirdparty%2Fdovecot%2Fcore.git lib-imap: NIL as astring is the same as "NIL" This is a bit klugdy but works as long as all callers use imap_arg_get_astring() instead of trying to handle it themselves. --- diff --git a/src/lib-imap/imap-arg.c b/src/lib-imap/imap-arg.c index f44498901a..8ca37fc764 100644 --- a/src/lib-imap/imap-arg.c +++ b/src/lib-imap/imap-arg.c @@ -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; diff --git a/src/lib-imap/imap-arg.h b/src/lib-imap/imap-arg.h index fb9df81060..870d4ccf82 100644 --- a/src/lib-imap/imap-arg.h +++ b/src/lib-imap/imap-arg.h @@ -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 || \