]> granicus.if.org Git - neomutt/commitdiff
imap: ensure '\0' and INBOX are the same Mailbox
authorMehdi Abaakouk <sileht@sileht.net>
Tue, 11 Dec 2018 18:00:21 +0000 (19:00 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Dec 2018 12:25:54 +0000 (12:25 +0000)
INBOX and '\0  was considered as different mailbox. But when '\0' was
opened, the path/realpath was updated to "INBOX".

This change fixes m->path, m->realpath at the beginning to ensure INBOX
and '\0' are the same Mailbox.

Related #1486

imap/imap.c

index d5d048e7db4c207faae39b239b161f9ba7b288e2..4591d86810c4dfd4d338b3d61b74726ab5754e6b 100644 (file)
@@ -1880,6 +1880,13 @@ int imap_ac_add(struct Account *a, struct Mailbox *m)
   {
     struct Url *url = url_parse(m->path);
     struct ImapMboxData *mdata = imap_mdata_new(adata, url->path);
+
+    /* fixup path and realpath, mainly to replace / by /INBOX */
+    char buf[LONG_STRING];
+    imap_qualify_path(buf, sizeof(buf), &adata->conn_account, mdata->name);
+    mutt_str_strfcpy(m->path, buf, sizeof(m->path));
+    mutt_str_strfcpy(m->realpath, m->path, sizeof(m->realpath));
+
     m->mdata = mdata;
     m->free_mdata = imap_mdata_free;
     url_free(&url);
@@ -1952,7 +1959,7 @@ int imap_login(struct ImapAccountData *adata)
  */
 static int imap_mbox_open(struct Mailbox *m, struct Context *ctx)
 {
-  if (!m || !m->account)
+  if (!m || !m->account || !m->mdata)
     return -1;
 
   char buf[PATH_MAX];
@@ -1963,10 +1970,6 @@ static int imap_mbox_open(struct Mailbox *m, struct Context *ctx)
   struct ImapAccountData *adata = imap_adata_get(m);
   struct ImapMboxData *mdata = imap_mdata_get(m);
 
-  imap_qualify_path(buf, sizeof(buf), &adata->conn_account, mdata->name);
-  mutt_str_strfcpy(m->path, buf, sizeof(m->path));
-  mutt_str_strfcpy(m->realpath, m->path, sizeof(m->realpath));
-
   // NOTE(sileht): looks like we have two not obvious loop here
   // ctx->mailbox->account->adata->ctx
   // mailbox->account->adata->mailbox