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;
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. */