Associate imap_user to an IMAP connection devel/issue-1663
authorPietro Cerutti <gahr@gahr.ch>
Thu, 23 May 2019 14:45:39 +0000 (14:45 +0000)
committerRichard Russon <rich@flatcap.org>
Mon, 21 Oct 2019 21:59:18 +0000 (22:59 +0100)
This allows to distinguish between two connection to the same host using
different usernames, when the username is not encoded in the URL.

Issue #1664

imap/imap.c
imap/util.c

index b3f746eb8496dfe68c0b827806db58124f1337bb..9a99fae65d84f8c00ecbb269c9f5de390efb96d8 100644 (file)
@@ -1815,6 +1815,8 @@ struct Account *imap_ac_find(struct Account *a, const char *path)
     return NULL;
 
   struct Url *url = url_parse(path);
+  if (!url->user && C_ImapUser)
+    url->user = C_ImapUser;
 
   struct ImapAccountData *adata = a->adata;
   struct ConnAccount *ac = &adata->conn_account;
index 34cd7d5f84b2efb6fe4c0a2117dfa2af90fbdeac..f6f79ce88304f26ebb15aa0704bbf7408a72f719 100644 (file)
@@ -641,6 +641,12 @@ int imap_parse_path(const char *path, struct ConnAccount *account, char *mailbox
   if (url->scheme == U_IMAPS)
     account->flags |= MUTT_ACCT_SSL;
 
+  if (C_ImapUser)
+  {
+    mutt_str_strfcpy(account->user, C_ImapUser, sizeof(account->user));
+    account->flags |= MUTT_ACCT_USER;
+  }
+
   mutt_str_strfcpy(mailbox, url->path, mailboxlen);
 
   url_free(&url);