]> granicus.if.org Git - mutt/commitdiff
Add RECURSIVEMATCH LIST-EXTENDED selection option to query.
authorKevin McCarthy <kevin@8t8.us>
Wed, 24 Apr 2019 02:06:11 +0000 (19:06 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 24 Apr 2019 22:50:11 +0000 (15:50 -0700)
LSUB is required to include mailboxes with subscribed children, but
the just added "LIST (SUBSCRIBED)" by default does not do that.

To match previous behavior, add RECURSIVEMATCH to make sure the
children are included.  Fix the parser to trim off the CHILDINFO
suffix in the response.

Parse \NonExistent LIST attribute the same as \NoSelect.

imap/browse.c
imap/command.c

index 8a2a9a6aae4bef13c70f00beb56b5f2ad2efa32e..ab9658034aa68f4c869ec4694cbb7aeb09bb3dd8 100644 (file)
@@ -46,7 +46,7 @@ int imap_browse (const char* path, struct browser_state* state)
   char buf[LONG_STRING*2];
   char mbox[LONG_STRING];
   char munged_mbox[LONG_STRING];
-  char list_cmd[18];
+  const char *list_cmd;
   int len;
   int n;
   int nsup;
@@ -69,18 +69,17 @@ int imap_browse (const char* path, struct browser_state* state)
 
   if (option (OPTIMAPLSUB))
   {
-    const char *lsub_cmd = "LSUB";
-
     /* RFC3348 section 3 states LSUB is unreliable for hierarchy information.
      * The newer LIST extensions are designed for this.
      */
     if (mutt_bit_isset (idata->capabilities, LIST_EXTENDED))
-      lsub_cmd = "LIST (SUBSCRIBED)";
-    strfcpy (list_cmd, lsub_cmd, sizeof (list_cmd));
+      list_cmd = "LIST (SUBSCRIBED RECURSIVEMATCH)";
+    else
+      list_cmd = "LSUB";
   }
   else
   {
-    strfcpy (list_cmd, "LIST", sizeof (list_cmd));
+    list_cmd = "LIST";
   }
 
   mutt_message _("Getting folder list...");
index 91457a114b1ab4737c38e2dfbea49d94000ea368..a7b44712e662e020948c8c814568f8abcadf3f22 100644 (file)
@@ -928,10 +928,11 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s)
   {
     if (!ascii_strncasecmp (s, "\\NoSelect", 9))
       list->noselect = 1;
+    else if (!ascii_strncasecmp (s, "\\NonExistent", 12)) /* rfc5258 */
+      list->noselect = 1;
     else if (!ascii_strncasecmp (s, "\\NoInferiors", 12))
       list->noinferiors = 1;
-    /* See draft-gahrns-imap-child-mailbox-?? */
-    else if (!ascii_strncasecmp (s, "\\HasNoChildren", 14))
+    else if (!ascii_strncasecmp (s, "\\HasNoChildren", 14)) /* rfc5258*/
       list->noinferiors = 1;
 
     s = imap_next_word (s);
@@ -958,12 +959,30 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s)
       idata->status = IMAP_FATAL;
       return;
     }
+
+    if (strlen(idata->buf) < litlen)
+    {
+      dprint (1, (debugfile, "Error parsing LIST mailbox\n"));
+      return;
+    }
+
     list->name = idata->buf;
+    s = list->name + litlen;
+    if (*s)
+    {
+      *s = '\0';
+      s++;
+      SKIPWS(s);
+    }
   }
   else
   {
-    imap_unmunge_mbox_name (idata, s);
     list->name = s;
+    /* Exclude rfc5258 RECURSIVEMATCH CHILDINFO suffix */
+    s = imap_next_word (s);
+    if (*s)
+      *(s - 1) = '\0';
+    imap_unmunge_mbox_name (idata, list->name);
   }
 
   if (list->name[0] == '\0')