char buf[PATH_MAX];
char mbox[PATH_MAX];
char munged_mbox[PATH_MAX];
- char list_cmd[5];
+ char list_cmd[18];
+ int len;
int n;
char ctmp;
bool showparents = false;
save_lsub = C_ImapCheckSubscribed;
C_ImapCheckSubscribed = false;
- mutt_str_strfcpy(list_cmd, C_ImapListSubscribed ? "LSUB" : "LIST", sizeof(list_cmd));
// Pick first mailbox connected to the same server
struct MailboxNode *np = NULL;
if (!adata)
goto fail;
+ if (C_ImapListSubscribed)
+ {
+ const char *lsub_cmd = "LSUB";
+
+ /* RFC3348 section 3 states LSUB is unreliable for hierarchy information.
+ * The newer LIST extensions are designed for this. */
+ if (adata->capabilities & IMAP_CAP_LIST_EXTENDED)
+ lsub_cmd = "LIST (SUBSCRIBED)";
+ mutt_str_strfcpy(list_cmd, lsub_cmd, sizeof(list_cmd));
+ }
+ else
+ {
+ mutt_str_strfcpy(list_cmd, "LIST", sizeof(list_cmd));
+ }
+
mutt_message(_("Getting folder list..."));
/* skip check for parents when at the root */
/* if our target exists and has inferiors, enter it if we
* aren't already going to */
imap_munge_mbox_name(adata->unicode, munged_mbox, sizeof(munged_mbox), mbox);
- snprintf(buf, sizeof(buf), "%s \"\" %s", list_cmd, munged_mbox);
+ len = snprintf(buf, sizeof(buf), "%s \"\" %s", list_cmd, munged_mbox);
+ if (adata->capabilities & IMAP_CAP_LIST_EXTENDED)
+ snprintf(buf + len, sizeof(buf) - len, " RETURN (CHILDREN)");
imap_cmd_start(adata, buf);
adata->cmdresult = &list;
do
snprintf(buf, sizeof(buf), "%s%%", mbox);
imap_munge_mbox_name(adata->unicode, munged_mbox, sizeof(munged_mbox), buf);
mutt_debug(LL_DEBUG3, "%s\n", munged_mbox);
- snprintf(buf, sizeof(buf), "%s \"\" %s", list_cmd, munged_mbox);
+ len = snprintf(buf, sizeof(buf), "%s \"\" %s", list_cmd, munged_mbox);
+ if (adata->capabilities & IMAP_CAP_LIST_EXTENDED)
+ snprintf(buf + len, sizeof(buf) - len, " RETURN (CHILDREN)");
if (browse_add_list_result(adata, buf, state, false))
goto fail;
"AUTH=GSSAPI", "AUTH=ANONYMOUS", "AUTH=OAUTHBEARER",
"STARTTLS", "LOGINDISABLED", "IDLE",
"SASL-IR", "ENABLE", "CONDSTORE",
- "QRESYNC", "X-GM-EXT-1", NULL,
+ "QRESYNC", "LIST-EXTENDED", "X-GM-EXT-1",
+ NULL,
};
/**
#define IMAP_CAP_ENABLE (1 << 13) ///< RFC5161
#define IMAP_CAP_CONDSTORE (1 << 14) ///< RFC7162
#define IMAP_CAP_QRESYNC (1 << 15) ///< RFC7162
-#define IMAP_CAP_X_GM_EXT_1 (1 << 16) ///< https://developers.google.com/gmail/imap/imap-extensions
+#define IMAP_CAP_LIST_EXTENDED (1 << 16) ///< RFC5258: IMAP4 LIST Command Extensions
+#define IMAP_CAP_X_GM_EXT_1 (1 << 17) ///< https://developers.google.com/gmail/imap/imap-extensions
-#define IMAP_CAP_ALL ((1 << 17) - 1)
+#define IMAP_CAP_ALL ((1 << 18) - 1)
/**
* struct ImapList - Items in an IMAP browser