summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-09-07 12:55:23 -0700
committerKevin McCarthy <kevin@8t8.us>2021-09-16 14:24:18 -0700
commit960afab461d1f72f64f322fe42738a91a066cc38 (patch)
tree14af33486aaf49d5380515df9b8d2e72ece78418
parent8bb11afe4094d7f87267d7823b399c2f828034e4 (diff)
Generate URLs with user/password as parsed.
This helps ensure they match for browser sticky-cursor, sidebar, and a few other places where a path is compared against something (e.g. $trash). Add two flags that track if the user/password came from the parsed URL. If they were instead added to the account via $imap_user or $imap_pass, don't include those when generating a URL string as output. Change LSUB to also include the password, if present in the original connection URL.
-rw-r--r--account.c13
-rw-r--r--account.h3
-rw-r--r--imap/command.c8
-rw-r--r--imap/util.c4
4 files changed, 22 insertions, 6 deletions
diff --git a/account.c b/account.c
index 7ef484f5..9fa13577 100644
--- a/account.c
+++ b/account.c
@@ -75,11 +75,13 @@ int mutt_account_fromurl (ACCOUNT* account, ciss_url_t* url)
{
strfcpy (account->user, url->user, sizeof (account->user));
account->flags |= MUTT_ACCT_USER;
+ account->flags |= MUTT_ACCT_USER_FROM_URL;
}
if (url->pass)
{
strfcpy (account->pass, url->pass, sizeof (account->pass));
account->flags |= MUTT_ACCT_PASS;
+ account->flags |= MUTT_ACCT_PASS_FROM_URL;
}
if (url->port)
{
@@ -134,10 +136,16 @@ void mutt_account_tourl (ACCOUNT* account, ciss_url_t* url)
url->host = account->host;
if (account->flags & MUTT_ACCT_PORT)
url->port = account->port;
- if (account->flags & MUTT_ACCT_USER)
+ if ((account->flags & MUTT_ACCT_USER) &&
+ (account->flags & MUTT_ACCT_USER_FROM_URL))
+ {
url->user = account->user;
- if (account->flags & MUTT_ACCT_PASS)
+ }
+ if ((account->flags & MUTT_ACCT_PASS) &&
+ (account->flags & MUTT_ACCT_PASS_FROM_URL))
+ {
url->pass = account->pass;
+ }
}
/* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */
@@ -253,6 +261,7 @@ int mutt_account_getpass (ACCOUNT *account)
void mutt_account_unsetpass (ACCOUNT* account)
{
account->flags &= ~MUTT_ACCT_PASS;
+ account->flags &= ~MUTT_ACCT_PASS_FROM_URL;
}
/* mutt_account_getoauthbearer: call external command to generate the
diff --git a/account.h b/account.h
index 9f485cfd..73f6e9d6 100644
--- a/account.h
+++ b/account.h
@@ -38,6 +38,9 @@ enum
#define MUTT_ACCT_LOGIN (1<<2)
#define MUTT_ACCT_PASS (1<<3)
#define MUTT_ACCT_SSL (1<<4)
+/* these are used to regenerate a URL in same form it was parsed */
+#define MUTT_ACCT_USER_FROM_URL (1<<5)
+#define MUTT_ACCT_PASS_FROM_URL (1<<6)
typedef struct
{
diff --git a/imap/command.c b/imap/command.c
index 340d5bb9..9088847a 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -1032,11 +1032,13 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
mutt_account_tourl (&idata->conn->account, &url);
url.path = list.name;
- if (!mutt_strcmp (url.user, ImapUser))
- url.user = NULL;
mailbox = mutt_buffer_pool_get ();
- url_ciss_tobuffer (&url, mailbox, 0);
+ /* Include password if it was part of the connection URL.
+ * This allows full connection using just the buffy url.
+ * It also helps with browser sticky-cursor and sidebar comparison,
+ * since the context->path will include the password too. */
+ url_ciss_tobuffer (&url, mailbox, U_DECODE_PASSWD);
mutt_buffy_add (mutt_b2s (mailbox), NULL, -1, -1);
mutt_buffer_pool_release (&mailbox);
diff --git a/imap/util.c b/imap/util.c
index cebc00f8..aed07388 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -377,6 +377,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
strfcpy (mx->account.user, tmp, sizeof (mx->account.user));
strfcpy (tmp, c+1, sizeof (tmp));
mx->account.flags |= MUTT_ACCT_USER;
+ mx->account.flags |= MUTT_ACCT_USER_FROM_URL;
}
if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1)
@@ -730,7 +731,8 @@ void imap_make_date (BUFFER *buf, time_t timestamp)
* Make an absolute IMAP folder target, given IMAP_MBOX and relative
* path.
*
- * Note this will include the password in the URL.
+ * Note this will include the password in the URL, if it was present in the
+ * account connection URL.
*/
void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path)
{