#3733: imap_check_subscribed interacts badly with account-hook
-------------------------+---------------------
Reporter: Lekensteyn | Owner: brendan
Type: defect | Status: new
Priority: major | Milestone:
Component: IMAP | Version:
Resolution: | Keywords:
-------------------------+---------------------
Comment (by Lekensteyn):
First, let's forget about the current behavior and consider what would be
expected instead.
Given {{{account-hook 'imaps://example.com'}}}, one likely wants to match
any account at that domain, whether an {{{imap_user}}} is set or not.
With {{{account-hook 'imaps://[email protected]/'}}}, one likely wants to
apply it to just {{{imap_user=user}}} (or
{{{folder=imaps://[email protected]/INBOX}}}), but not
{{{imaps://[email protected]}}}.
There could also be a case where one has an authenticated and an
unauthenticated user (do these even exist?). In the even that this should
be supported, there could probably be a match for {{{account-hook
'imaps://@example.com}}}.
Now back to the current implementation. Right now the behavior is
inconsistent when a user is given via the folder URL and `imap_user`. It
then flips between branching {{{url.user = NULL}}}, and not branching it.
This cannot be correct.
Regardless of this patch, these cases would not trigger the hook:
{{{
set folder=imaps://[email protected]
set imap_user=user
account-hook 'imaps://example.com' 'set imap_pass=secret'
}}}
nor woukd this one:
{{{
set folder=imaps://[email protected]
account-hook 'imaps://example.com' 'set imap_user=user imap_pass=secret'
}}}
For these snippets, it still works:
{{{
set folder=imaps://example.com
account-hook 'imaps://example.com' 'set imap_user=user imap_pass=secret'
}}}
and
{{{
set folder=imaps://example.com
set imap_user=user
account-hook 'imaps://example.com' 'set imap_pass=secret'
}}}
(I have actually tested these cases with the patch applied and {{{account-
hook . 'unset imap_user imap_pass}}} as recommended.)
Should you want to match *any* account on the domain, then you could use
this configuration instead:
{{{
folder-hook '[email protected]' 'set spoolfile=+INBOX'
}}}
Why the leading dot? Because '@' expands to a user, thus resulting in an
empty pattern which matches everything. I will attach a patch for that too
(also tested).
Finally treating your last comment whether {{{imap_user}}} can be left
unset, yes it could, but only if done for every domain. When at least one
domain has a matching username, then the bug may occur (see example config
in commit message).
--
Ticket URL: <http://dev.mutt.org/trac/ticket/3733#comment:2>
Mutt <http://www.mutt.org/>
The Mutt mail user agent