fix parsing of NIL hierarchy delimiters in IMAP LIST responses

a server which does not support hierarchical mailboxes (e.g., seznam.cz
as of oct 2018) can legitimately send NIL (rather than an empty string).
This commit is contained in:
Oswald Buddenhagen 2019-05-28 17:27:09 +02:00
parent 2e515bf842
commit fbc432aace

View File

@ -1197,17 +1197,16 @@ parse_response_code( imap_store_t *ctx, imap_cmd_t *cmd, char *s )
return RESP_OK; return RESP_OK;
} }
static int parse_list_rsp_p1( imap_store_t *, list_t *, char * );
static int parse_list_rsp_p2( imap_store_t *, list_t *, char * ); static int parse_list_rsp_p2( imap_store_t *, list_t *, char * );
static int static int
parse_list_rsp( imap_store_t *ctx, list_t *list, char *cmd ) parse_list_rsp( imap_store_t *ctx, list_t *list, char *cmd )
{ {
char *arg;
list_t *lp; list_t *lp;
if (!is_list( list )) { if (!is_list( list )) {
free_list( list ); free_list( list );
bad_list:
error( "IMAP error: malformed LIST response\n" ); error( "IMAP error: malformed LIST response\n" );
return LIST_BAD; return LIST_BAD;
} }
@ -1217,10 +1216,19 @@ parse_list_rsp( imap_store_t *ctx, list_t *list, char *cmd )
return LIST_OK; return LIST_OK;
} }
free_list( list ); free_list( list );
if (!(arg = next_arg( &cmd ))) return parse_list( ctx, cmd, parse_list_rsp_p1 );
goto bad_list; }
if (!ctx->delimiter[0])
ctx->delimiter[0] = arg[0]; static int
parse_list_rsp_p1( imap_store_t *ctx, list_t *list, char *cmd ATTR_UNUSED )
{
if (!is_opt_atom( list )) {
error( "IMAP error: malformed LIST response\n" );
free_list( list );
return LIST_BAD;
}
if (!ctx->delimiter[0] && is_atom( list ))
ctx->delimiter[0] = list->val[0];
return parse_list( ctx, cmd, parse_list_rsp_p2 ); return parse_list( ctx, cmd, parse_list_rsp_p2 );
} }