summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-07-06 20:17:59 -0700
committerKevin McCarthy <kevin@8t8.us>2020-07-06 20:17:59 -0700
commitb48f8e1e1510ff1560921a912aa124043a936f05 (patch)
treedf40504ad61c1477587a49ca31365a192f24067d /imap
parent25f82cf6031c9c37696590924858cf553f51596f (diff)
Directly add/remove mailboxes for IMAP.
The LSUB processor along with <subscribe> and <unsubscribe> would construct a mailboxes command and send it to the muttrc parser. Since the poll/label refactor it's much easier to just directly call the functions, and is much more secure. So do that instead.
Diffstat (limited to 'imap')
-rw-r--r--imap/command.c25
-rw-r--r--imap/imap.c16
2 files changed, 12 insertions, 29 deletions
diff --git a/imap/command.c b/imap/command.c
index 1cf02257..5ca04bf0 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -1005,9 +1005,7 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s)
static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
{
- char buf[STRING];
- char quoted_name[STRING];
- BUFFER err;
+ BUFFER *mailbox = NULL;
ciss_url_t url;
IMAP_LIST list;
@@ -1031,23 +1029,16 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
dprint (3, (debugfile, "Subscribing to %s\n", list.name));
- strfcpy (buf, "mailboxes \"", sizeof (buf));
mutt_account_tourl (&idata->conn->account, &url);
- /* escape \ and ". Also escape ` because the resulting
- * string will be passed to mutt_parse_rc_line. */
- imap_quote_string_and_backquotes (quoted_name, sizeof (quoted_name), list.name);
- url.path = quoted_name + 1;
- url.path[strlen(url.path) - 1] = '\0';
+ url.path = list.name;
if (!mutt_strcmp (url.user, ImapUser))
url.user = NULL;
- url_ciss_tostring (&url, buf + 11, sizeof (buf) - 11, 0);
- safe_strcat (buf, sizeof (buf), "\"");
- mutt_buffer_init (&err);
- err.dsize = STRING;
- err.data = safe_malloc (err.dsize);
- if (mutt_parse_rc_line (buf, &err))
- dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", err.data));
- FREE (&err.data);
+
+ mailbox = mutt_buffer_pool_get ();
+ url_ciss_tobuffer (&url, mailbox, 0);
+
+ mutt_buffy_add (mutt_b2s (mailbox), NULL, -1);
+ mutt_buffer_pool_release (&mailbox);
}
/* cmd_parse_myrights: set rights bits according to MYRIGHTS response */
diff --git a/imap/imap.c b/imap/imap.c
index fab91837..dcd2686f 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2267,8 +2267,6 @@ int imap_subscribe (char *path, int subscribe)
IMAP_DATA *idata;
char buf[LONG_STRING*2];
char mbox[LONG_STRING];
- int mblen;
- BUFFER err;
IMAP_MBOX mx;
if (!mx_is_imap (path) || imap_parse_path (path, &mx) || !mx.mbox)
@@ -2285,16 +2283,10 @@ int imap_subscribe (char *path, int subscribe)
if (option (OPTIMAPCHECKSUBSCRIBED))
{
- mutt_buffer_init (&err);
- err.dsize = STRING;
- err.data = safe_malloc (err.dsize);
- mblen = snprintf (mbox, sizeof (mbox), "%smailboxes ",
- subscribe ? "" : "un");
- imap_quote_string_and_backquotes (mbox + mblen, sizeof(mbox) - mblen,
- path);
- if (mutt_parse_rc_line (mbox, &err))
- dprint (1, (debugfile, "Error adding subscribed mailbox: %s\n", err.data));
- FREE (&err.data);
+ if (subscribe)
+ mutt_buffy_add (path, NULL, -1);
+ else
+ mutt_buffy_remove (path);
}
if (subscribe)