From: Brendan Cully Date: Thu, 10 Aug 2006 06:02:08 +0000 (+0000) Subject: Handle literal mailbox names in LIST responses (for Notes). X-Git-Tag: mutt-1-5-13-rel~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d26a857420b92d92af5a0f57baad44b07579475;p=mutt Handle literal mailbox names in LIST responses (for Notes). We should really have an IMAP stream tokenizer. --- diff --git a/imap/command.c b/imap/command.c index 59a2b4d6..cc4ed391 100644 --- a/imap/command.c +++ b/imap/command.c @@ -581,6 +581,7 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s) IMAP_LIST* list; IMAP_LIST lb; char delimbuf[5]; /* worst case: "\\"\0 */ + long litlen; if (idata->cmddata) list = (IMAP_LIST*)idata->cmddata; @@ -623,9 +624,22 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s) /* Name */ s = imap_next_word (s); - imap_unmunge_mbox_name (s); - list->name = s; - + /* Notes often responds with literals here. We need a real tokenizer. */ + if (!imap_get_literal_count (s, &litlen)) + { + if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) + { + idata->status = IMAP_FATAL; + return; + } + list->name = idata->buf; + } + else + { + imap_unmunge_mbox_name (s); + list->name = s; + } + if (list->name[0] == '\0') { idata->delim = list->delim; diff --git a/imap/util.c b/imap/util.c index c8a18b2e..6802bde3 100644 --- a/imap/util.c +++ b/imap/util.c @@ -328,15 +328,17 @@ int imap_get_literal_count(const char *buf, long *bytes) char *pc; char *pn; - if (!(pc = strchr (buf, '{'))) - return (-1); + if (!buf || !(pc = strchr (buf, '{'))) + return -1; + pc++; pn = pc; while (isdigit ((unsigned char) *pc)) pc++; *pc = 0; *bytes = atoi(pn); - return (0); + + return 0; } /* imap_get_qualifier: in a tagged response, skip tag and status for