]> granicus.if.org Git - mutt/commitdiff
Handle literal mailbox names in LIST responses (for Notes).
authorBrendan Cully <brendan@kublai.com>
Thu, 10 Aug 2006 06:02:08 +0000 (06:02 +0000)
committerBrendan Cully <brendan@kublai.com>
Thu, 10 Aug 2006 06:02:08 +0000 (06:02 +0000)
We should really have an IMAP stream tokenizer.

imap/command.c
imap/util.c

index 59a2b4d6a36b23a8b0f947b9682b4b39f6fb6c49..cc4ed391a66b7023f7594718cf3493b2a2ee404d 100644 (file)
@@ -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;
index c8a18b2e451a1068398ff2af5066fd880e1f4b8f..6802bde34109f13d38ff68829acae38ef21f1968 100644 (file)
@@ -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