Kevin McCarthy [Sat, 28 Jul 2018 19:59:35 +0000 (12:59 -0700)]
Fix AUXSORT usage in compare_spam.
AUXSORT already checks if the first parameter is zero.
Additionally, the macro expands into more than one statement, so
putting inside an unbracketed if is misleading and generates a
warning on the latest gcc.
Fortunately, both statements checked if the first parameter was zero,
so no actual bug resulted.
Ken Moffat [Thu, 26 Jul 2018 22:34:50 +0000 (15:34 -0700)]
Fix manual.pdf toc page numbers.
When TeX engines are not run sufficient times there are undefined
references - for manual.tex the page numbers in the Table of
Contents and the List of Tables render as '??'. In this case:
Kevin McCarthy [Thu, 26 Jul 2018 00:52:40 +0000 (17:52 -0700)]
Add mx_ops.msg_padding_size to return the padding for a mx type.
Mbox pads with a 1 byte, while mmdf pads with 10. Because compress
depends on the child type, we create a mx_ops, which allows compress.c
to delegate to the child ops.
Kevin McCarthy [Wed, 25 Jul 2018 01:23:25 +0000 (18:23 -0700)]
Skip sort in mbox_sync_mailbox() when new/reopen occurs.
Callers of mx_sync_mailbox() and mx_close_mailbox() already check for
those cases and call update_index(). So remove the need_sort flag
setting when mbox_check_mailbox() returns new/reopen inside
mbox_sync_mailbox().
Kevin McCarthy [Wed, 25 Jul 2018 01:12:20 +0000 (18:12 -0700)]
Handle reopen/new_mail when closing mailbox in <imap-logout-all>.
Other callers, such as OP_QUIT, OP_MAIN_CHANGE_FOLDER, and
OP_MAIN_SYNC_FOLDER handle the case where a sync or close_mailbox
fails due to new mail or a reopen.
OP_MAIN_LOGOUT_ALL appears to have been accidentally missed. Add a
call to update_index() to properly sort and update vcounts.
Vincent Lefevre [Tue, 24 Jul 2018 01:52:41 +0000 (03:52 +0200)]
Add ctx->vsize = 0 in a couple of places.
It is not clear whether this is needed, but in both cases, the old value
(if not 0) is obsolete. If there is a bug somewhere else about vsize, it
will be easier to notice it.
Vincent Lefevre [Sun, 22 Jul 2018 00:57:32 +0000 (02:57 +0200)]
Improved limit-to-all detection by skipping leading spaces of the pattern.
There are many equivalent limit-to-all patterns, but in practice, one
may want to limit to " ~A" in order to prevent the pattern from being
recorded in the history. Thus it is important to detect at least this
pattern and similar ones.
Vincent Lefevre [Sat, 21 Jul 2018 23:46:03 +0000 (01:46 +0200)]
Bug fix: reset ctx->vsize in update_index_unthreaded on reopened mailbox.
This fixes a bug observed when doing the following:
1. Start Mutt on some mailbox.
2. Limit the view.
3. Set sort by date (thus unthreaded).
4. Set $status_format to display the size of the messages shown (%L).
5. Copy a message matching the limit pattern to this mailbox.
6. With another Mutt instance, remove this message from this mailbox.
7. Move the cursor to update the view.
Result: one was getting a value equal to twice the initial size.
Kevin McCarthy [Fri, 20 Jul 2018 03:28:38 +0000 (20:28 -0700)]
Display matching new messages in a thread-limited index.
Previously, the index performed pattern matching first, and then
resorted new mail. The problem was that thread-limiting patterns,
e.g. ~(pattern), require threading data to properly match against the
new messages.
We already save new messages for the purposes of uncollapsing threads.
To keep the code cleaner, split off update_index() into
update_index_threaded()/unthreaded(). Then for threaded mode, save
the new messages first. We can then sort (before pattern matching),
and use the save_new array to pattern match the new messages
afterwards.
The $uncollapse_new loop was unnecessarily performing a n^2 search.
Simplify to just iteratate over the save_new instead.
Brandon Long [Tue, 26 Jun 2018 22:42:08 +0000 (15:42 -0700)]
Improve OAUTHBEARER support.
Move token refresh commands to their own config variables. Consolidate
code for refreshing tokens and generating the SASL OAUTHBEARER
argument in account.c. Add support for OAUTHBEARER to pop.
Fix pop_auth_oauth() mutt_from_base64() call from 1.10.1 release.
Kevin McCarthy [Sun, 8 Jul 2018 02:03:44 +0000 (19:03 -0700)]
Properly quote IMAP mailbox names when (un)subscribing.
When handling automatic subscription (via $imap_check_subscribed), or
manual subscribe/unsubscribe commands, mutt generating a "mailboxes"
command but failed to properly escape backquotes.
Thanks to Jeriko One for the detailed bug report and patch, which this
commit is based upon.
Kevin McCarthy [Wed, 27 Jun 2018 16:27:05 +0000 (09:27 -0700)]
Reset all MonitorContext state on context removal.
Reset both the descriptor and changed flag when the current context is
removed. Don't make this dependent on the context being valid or
being found by monitor_resolve(), in case the context was closed due
to some type of error condition.
Kevin McCarthy [Wed, 27 Jun 2018 02:48:25 +0000 (19:48 -0700)]
Fix MonitorContextDescriptor update on removal.
Reset the context descriptor before checking for the monitor being
shared by another mailbox. Technically, it would be set properly
during the next add, but it shouldn't be left incorrect.
Kevin McCarthy [Tue, 26 Jun 2018 00:54:43 +0000 (17:54 -0700)]
Work around open mailbox monitor code check issue.
The monitor code is too fast, and can result in all the changes for a
single directory stat update being missed.
Work around this issue by not recording stat time updates when the
check_mailbox() is triggered by the monitor. This will cause the next
subsequent check to take another look.
Kevin McCarthy [Mon, 25 Jun 2018 20:13:55 +0000 (13:13 -0700)]
Generate error if makedoc is missing a type.
Add a comment in init.h to remind devs to update makedoc.c when adding
a new type.
Change makedoc to fail on a missing type. Otherwise it's too easy to
miss the resulting problem in the documentation.
Credit goes to Eike Rathke for noting that it was too easy to forget
to do this, and something should be fixed. I found his solution a bit
too complicated though, and opted for just adding comment and program
failure.
Eike Rathke [Sat, 23 Jun 2018 08:25:15 +0000 (10:25 +0200)]
Make make ctags actually work
make ctags broke with
Making ctags in po
make[1]: Entering directory '.../mutt/po'
make[1]: *** No rule to make target 'ctags'. Stop.
make[1]: Leaving directory '.../mutt/po'
Makefile:867: recipe for target 'ctags-recursive' failed
make: *** [ctags-recursive] Error 1
and once fixed the same in intl/
Note that this ctags target scatters tags files over directories.
If you use exuberant ctags then simply run
ctags -R
once in mutt's root dir instead.
Eike Rathke [Mon, 18 Jun 2018 20:04:47 +0000 (22:04 +0200)]
Allow larger passphrase timeout values
This came up in the comp.mail.mutt newsgroup where a user wasn't
satisfied with the SHORT_MAX seconds ~9 hours limit on passphrase
timeouts.
For the first time made it necessary for the options parser to be
able to parse numbers as long values. Also, introduced
mutt_add_timeout() to detect possible overflow before adding a
timeout to a time_t value and truncate to TIME_T_MAX instead.
Kevin McCarthy [Thu, 14 Jun 2018 08:17:56 +0000 (16:17 +0800)]
Convert context and buffy to use nanosecond timestamps.
The inotify interface has an unfortunate side effect of making Mutt
react too quickly to new mail. Sometimes, the mail is only
half-delivered when the mailbox is checked. Because Mutt is using the
stat mtime - seconds resolution - this means it won't realize there
are more messages delivered during the same second.
Nanosecond resolution fields were standardized in POSIX.1-2008, so
check for and use those if they are available.
Brandon Long [Mon, 11 Jun 2018 17:39:49 +0000 (10:39 -0700)]
Initial support for OAUTHBEARER for IMAP.
Gmail supports RFC 7628 for using OAUTH with IMAP, and they really don't
like you using password based auth. You can still enable "less secure
apps" and then generate an application specific password, but I figured it
was time to support it.
Being mutt, I punted on some of the "hard" work to an external script, ie
getting/refreshing the OAUTH tokens. This avoids the issue of how do you
have a client-id and client-secret for an open source project, and the fact
that OAUTH discovery is still nascent, so you'd likely need separate things
for each of the providers.
At least for Gmail, you can use the oauth2.py script from Google's
gmail-oauth2-tools:
https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py
You'd need to get your own oauth client credentials for Gmail here:
https://console.developers.google.com/apis/credentials
Then, you'd use oauth2.py with --generate_oauth2_token to get a refresh
token, and configure mutt with:
set imap_authenticators="oauthbearer"
set imap_user="<email_address>"
set imap_pass=`/path/to/oauth2.py --quiet --user=<email_address>
--client_id=<client_id> --client_secret=<client_secret>
--refresh_token=<refresh_token>`
For this patch, I didn't add any new configuration, but I'm open to
suggestions on that.
The patch also only support SASL-IR to reduce round-trips to the server,
but it's certainly possible to change that if we think there are
OAUTHBEARER IMAP servers that don't support SASL-IR. It also requires the
connection to be encrypted as the access token is re-usable for an hour or
so. Again, Gmail only allows encrypted IMAP connections, not sure if any
OAUTHBEARER services allow non-encrypted.
Turns out that auth failure leaves you in SASL mode, so I have a hack to
issue a noop command on error. Not sure if that's just OAUTHBEARER
oddness, or whether I should be using lower level mutt imap functions.
Kevin McCarthy [Wed, 6 Jun 2018 00:38:44 +0000 (17:38 -0700)]
Quick fix for ncurses buffering issue with inotify polling.
Ncurses does its own buffering for some character sequences, notable
Esc-prefixed input. Add a non-blocking check for getch() before
performing the mutt_monitor_poll() call.
This is a quick fix, which I'll clean up more later.
Kevin McCarthy [Tue, 5 Jun 2018 04:31:33 +0000 (21:31 -0700)]
Add GnuPG status fd checks for inline pgp.
The difficulty is that "BEGIN PGP MESSAGE" could be a signed and
armored part, so we can't fail hard if it isn't encrypted.
Change pgp_check_decryption_okay() to return more status codes, with
>=0 indicating an actual decryption; -2 and -1 indicating plaintext
found; and -3 indicating an actual DECRYPTION_FAILED status code seen.
Fail hard on -3, but change the message for -2 and -1 to indicate the
message was not encrypted.
Kevin McCarthy [Mon, 4 Jun 2018 22:40:57 +0000 (15:40 -0700)]
Add $pgp_check_gpg_decrypt_status_fd.
If set (the default) mutt performs more thorough checking of the
$pgp_decrypt_command status output for GnuPG result codes.
Ticket #39 revealed that GnuPG (currently) does not protect against
messages that have been manipulated to contain an empty encryption
packet followed by a plaintext packet.
A huge thanks to Marcus Brinkmann for researching this issue, taking
the time to report it to us (and the GnuPG team), and taking even more
time to clarify exactly what needed to be checked for.
Kevin McCarthy [Mon, 4 Jun 2018 01:34:21 +0000 (18:34 -0700)]
Add new timeout functions to work with inotify monitors.
The ncurses timeout() function doesn't affect the new poll inside
mutt_monitor_poll(). This meant that $imap_keepalive and $timeout
were not being respected when the monitor was used.
Create mutt_getch_timeout(), which delegates to timeout() and sets a
timeout value mutt_monitor_poll() uses too.
Kevin McCarthy [Sun, 3 Jun 2018 21:52:37 +0000 (14:52 -0700)]
Revert showing real size for small files in mutt_pretty_size().
I thought the change made in 0fa64ba9 was small enough not to matter,
but at least one long-time user took the time to track down the change
and request it be reverted.
Kevin McCarthy [Sun, 3 Jun 2018 21:05:13 +0000 (14:05 -0700)]
Change direct mutt_getch() callers to handle new mail event.
The inotify handler now returns -2 (timeout) on a new mail event.
Change the direct callers to ignore, so prompts aren't strangely
aborted.
Also, fix mutt_change_flag() to call mutt_refresh() before the
prompt. Apparently ncurses getch() was doing this for us, but now
that we are polling STDIN instead, the prompt wasn't displaying.
Kevin McCarthy [Mon, 21 May 2018 20:33:14 +0000 (13:33 -0700)]
Fix mutt_strncmp size comparison for 'uncolor header'.
Thanks to Fabian Groffen for pointing out the discrepancy.
mutt_extract_token() null-terminates the token,, so actually there is
no need to use "strncmp" for the comparison in this case.
However, since the token is being checked against Fields there is no
potential harm of a prefix match, so we should fix the number to be
consistent with the other token comparisons.
Kevin McCarthy [Sat, 28 Apr 2018 20:21:42 +0000 (13:21 -0700)]
Update pattern documentation.
Note that ~b, ~B, ~h, ~M, and ~X read the message in, and that this
can be much slower.
Change =b, =B, =h table rows to document just the IMAP behavior. The
"=" simple string behavior is already covered below, and makes it less
obvious whether "***)" should be added to those entries in the table.
Break up the simple string and imap server-side matching explanation
into two paragraphs.
Add ~M to the list of patterns you can't use message scoring with.
Add equivalent, if briefer, explanations to the muttrc.man page.
Kevin McCarthy [Mon, 30 Apr 2018 23:17:52 +0000 (16:17 -0700)]
Add more explanation of known vs subscribed lists to manual.
Mention in both the "Mailing Lists" and "Handling Mailing Lists"
sections the difference between known and subscribed mailing lists.
Note that the Mail-Followup-To header is generated if any of the
recipients are known mailing lists. If any of those are subscribed
mailing lists, the sender's address will not be in the header. If all
of them are known (but not subscribed), the sender's address will be
added to the header.
Kevin McCarthy [Thu, 19 Apr 2018 20:51:07 +0000 (13:51 -0700)]
Add $browser_abbreviate_mailboxes.
This allows '=' and '~' mailboxes shortcuts to be turned off in the
browser mailbox list.
The default $sort_browser value of "alpha" uses strcoll(3), which
ignores some punctuation. When using multiple accounts with
dynamically changing values of $folder, this can lead to an
unintuitive sorting order. (See issue #22 for an example.)
This problem came about because of commit 8328ce68, which enabled
mutt_pretty_mailbox() calls for IMAP and POP mailboxes too. The
commit had a valid point about consistency and too-wide mailbox
listings, so I don't really want to revert it.
This option provides an alternative to completely enable/disable the
shortcuts for those who run into an issue.