Kevin McCarthy [Sat, 13 May 2017 01:31:36 +0000 (18:31 -0700)]
Add $history_remove_dups option to remove dups from history ring.
When set, duplicate entries will be removed from the history ring when
a new entry is added. The duplicate removal rearranges the history
ring such that created empty slots are right after the "last" position
in the ring, preserving the most history.
Rewrite the next/prev functions to take into account that blank slots can
now be in the middle of the array.
Kevin McCarthy [Fri, 12 May 2017 16:15:00 +0000 (09:15 -0700)]
Turn IMAP_EXPUNGE_EXPECTED back off when syncing. (closes #3940).
imap_sync_mailbox() turned on IMAP_EXPUNGE_EXPECTED when issuing a
EXPUNGE command during a sync. However, it forgot to turn it back off.
That meant that an unexpected EXPUNGE that occurred during a
mx_check_mailbox -> imap_check_mailbox() -> imap_cmd_finish() call was
not setting
idata->check_status = IMAP_EXPUNGE_PENDING;
and so imap_check_mailbox() was not returning MUTT_REOPENED.
This meant that although the Context had been changed, the index did
not run update_index(), resulting in a possible segfault.
Thanks to Uroš Juvan for reporting the issue, and his invaluable
description of how to reproduce the problem.
Kevin McCarthy [Tue, 9 May 2017 23:07:46 +0000 (16:07 -0700)]
Create R_PAGER_FLOW config variable flag.
Use this for $header_color_partial, $markers, and $smart_wrap. When
these options are changed in the pager, this flag will force a
recalculation of lineInfo.
Remove the manual checks in OP_ENTER_COMMAND for $markers and
$smart_wrap, and instead use the same REDRAW_FLOW processing used for
a SigWinch.
Kevin McCarthy [Tue, 9 May 2017 23:07:42 +0000 (16:07 -0700)]
Rename REDRAW_SIGWINCH to REDRAW_FLOW.
The next patch will attach this redraw flag to pager settings. The
former name becomes somewhat confusing with the expanded usage, so
rename it to something more relevant to what is being redrawn.
Kevin McCarthy [Tue, 9 May 2017 01:48:25 +0000 (18:48 -0700)]
Add $header_color_partial to allow partial coloring of headers.
When set, a regexp match will color only the matched text in the
header. When unset (the default), the entire header will have color
applied.
With appropriate regexps, this allows coloring of just the header
field name. Of course, it can also be used to highlight arbitrary
phrases in the headers too.
Kevin McCarthy [Sun, 7 May 2017 22:11:43 +0000 (15:11 -0700)]
Improve maildir and mh to report flag changes in mx_check_mailbox() (closes #3865)
mx_check_mailbox() would update the header flags, but was not
returning MUTT_FLAGS back to the index loop. That meant a screen
redraw was needed to be notified of externally modified flags.
Change maildir_update_flags() to return 1 if the flags were actually
changed. Change maildir_check_mailbox() and mh_check_mailbox() to
return MUTT_FLAGS when that happens.
Thanks to jcdenton and mike-burns for the original patch.
Kevin McCarthy [Fri, 5 May 2017 20:55:31 +0000 (13:55 -0700)]
Don't modify LastFolder/CurrentFolder upon aborting a change folder operation.
Set LastFolder and CurrentFolder after mx_close_mailbox() has
successfully completed. Otherwise, if the close is aborted, they will
have incorrect values.
Kevin McCarthy [Fri, 5 May 2017 19:46:36 +0000 (12:46 -0700)]
Change message modifying operations to additively set redraw flags.
With the ability to set redraw flags with the menu stack operations,
some operations internally modify the current menu redraw flag.
For instance, _mutt_set_flag() can now set REDRAW_SIDEBAR.
Change the ops that modify messages to use 'redraw |= REDRAW_X'
instead of overwriting the flag value.
Kevin McCarthy [Fri, 5 May 2017 01:05:06 +0000 (18:05 -0700)]
Fix sidebar count updates when closing mailbox. (closes #3938)
The context unread and flagged counts were being updated too early in
mx_close_mailbox(). Cancelling at any of the following prompts would
leave them in an incorrect state. Additionally, $move could increase
the delete count (for flagged messages), and $delete, if answered no,
could turn off message deletion.
Move all the sidebar buffy stat updating to the bottom of the
function, after all the prompts and processing.
Kevin McCarthy [Sun, 30 Apr 2017 21:24:37 +0000 (14:24 -0700)]
Fix unused function warnings when sidebar is disabled. (closes #3936)
parse_path_list/unlist are currently only used by the
un/sidebar_whitelist commands. Add an ifdef around them to stop an
unused function warning. Add a comment too, so it's clear why they
are ifdef'ed.
Kevin McCarthy [Fri, 28 Apr 2017 04:22:08 +0000 (21:22 -0700)]
Fix km_error_key() infinite loop and unget buffer pollution.
'bind pager \Ch help' produces an infinite loop when an unbound key is
pressed in the pager. The reason is because km_error_key() tries to
verify that the key sequence is really bound to the OP_HELP operation.
It does this by using km_expand_key(), tokenize_unget_string() on the
resulting buffer, then checking if the next km_dokey() returns OP_HELP.
The problem is that km_expand_key() does not always produce a string
that is properly reparsed by tokenize_unget_string(). Control-h
sequences are expanded to ^H. tokenize_unget_string() recognizes this
as two characters '^' and 'H'. km_error_key() checks the OP returned,
which is OP_PAGER_TOP for the '^'. This is not OP_HELP, so it prints
a generic error and returns. This leaves the 'H' in the input buffer!
Since 'H' (by default) is unbound in the pager, it retriggers
km_error_key(), resulting in an infinite loop.
The same issues can occur without control sequences:
bind generic ? noop
bind generic dq help
In the index, hitting an unbound key will end up leaving 'q' in the unget
buffer, because 'd' is bound in the index menu and will be read by km_dokey().
A simple approach to fix this would be to just use the same code as in
mutt_make_help(), which has no double-check. This would be no worse
than the help menu, but can generate an inaccurate error message (e.g
if '?' were bound to noop)
This patch instead uses OP_END_COND as a barrier in the unget buffer.
It directly inserts the keys in the OP_HELP keymap, instead of using
km_expand_key() + tokenize_unget_string(). After calling km_dokey()
it flushes the unget buffer to the OP_END_COND barrier.
Thanks to Walter Alejandro Iglesias for reporting the bug.
Roger Cornelius [Wed, 26 Apr 2017 22:40:34 +0000 (15:40 -0700)]
Fix error message when opening a mailbox with no read permission. (closes #3934)
ctx->mx_ops ends up being NULL for both the case that ctx->magic is 0
and -1. This meant the mutt_perror() error message was never being
printed, because the check for ctx->mx_ops == NULL was taking place
first.
Move the "ctx->magic == -1" check first, so mutt will print out an
appropriate perror message in that case.
Kevin McCarthy [Tue, 18 Apr 2017 20:13:00 +0000 (13:13 -0700)]
Revert sort prompt labels. (see #3930)
Using the (s)ort style may look a bit better, but it makes the prompt
over 80 columns. The multichoice prompt supports multiple lines now,
but it is better to have it fit on one line if possible.
Revert back to the "capital letter" method, but leave the ticket open,
to explore other ideas that Vincent and chdiza have for better ways to
present a long choice like this.
Kevin McCarthy [Tue, 18 Apr 2017 19:25:17 +0000 (12:25 -0700)]
Fix GPG_TTY to be added to envlist. (closes #3931)
Changeset 37209157e33c converted filters to use the envlist.
Unfortunately, I missed that pgp.c sets GPG_TTY when using the GnuPG
agent. Convert to add GPG_TTY to the envlist too.
Kevin McCarthy [Tue, 18 Apr 2017 00:40:15 +0000 (17:40 -0700)]
Handle the pager sort prompt inside the pager.
Display the prompt in the pager, so a multiline prompt or resize
doesn't refresh the index menu. Then, bounce back through the index
to handle resorting and status line updates.
Kevin McCarthy [Sat, 8 Apr 2017 21:21:15 +0000 (14:21 -0700)]
Ensure mutt stays in endwin during calls to pipe_msg() (closes #3929)
The previous commit solved the problem reported in #3929: progressbar
output while downloading a message via IMAP was refreshing the mutt
ncurses session after launching the pipe program.
To ensure another place in the code doesn't inadvertantly generate
output, wrap OPTKEEPQUIET around the calls to
pipe_msg()/mutt_wait_filter() too.
Kevin McCarthy [Sat, 8 Apr 2017 21:18:26 +0000 (14:18 -0700)]
Silence imap progress messages for pipe-message. (see #3929)
_mutt_pipe_message() calls endwin(), and then calls pipe_msg(). If an
imap message body hasn't already been downloaded, this can end up
calling imap_fetch_message().
The progress messages in imap_fetch_message() were restoring curses,
just after extract_url was running. This was leading to a condition
where mutt curses didn't think the screen had changed after
extract_url exited.
There was already a check for isendwin() inside imap_fetch_message(),
but it wasn't wrapped around the progressbar creation/usage. Add a
check for those places too.
Kevin McCarthy [Wed, 5 Apr 2017 23:09:39 +0000 (16:09 -0700)]
Don't create query menu until after initial prompt. (see #3877)
A resize in the prompt will trigger a redraw, but the data won't be
loaded yet, displaying a blank screen instead of the previous menu.
Once the query is done, the data is loaded, but the menu->redraw state
has been changed by the resize.
We could manually flag a redraw, but it makes more sense visually
logically to just create the menu after the query and results are
loaded.
Kevin McCarthy [Sat, 1 Apr 2017 01:15:31 +0000 (18:15 -0700)]
Remove refresh parameter from mutt_enter_fname().
Also remove it from mutt_save_message(), which used it to pass through
to mutt_enter_fname(). The callers of this already had redraw logic,
to which REDRAW_STATUS merely needed to be added.
Kevin McCarthy [Sat, 1 Apr 2017 01:15:28 +0000 (18:15 -0700)]
Create R_MENU redraw option.
Previously, the R_INDEX option meant both the index as well as all
other menus. The removal of the OPTFORCEREDRAWINDEX option caused problems
with redrawing other menus for options such as arrow_cursor.
One solution would be change R_INDEX back to meaning "everything"
except pager, but there are only a handful of options that affect
other menus.
Instead, create R_MENU to indicate options that affect either all
menus or one of the other menus beside the index and pager.
Kevin McCarthy [Mon, 27 Mar 2017 01:31:43 +0000 (18:31 -0700)]
Remove redraw parameter from crypt send_menus.
The parameter was used to notify the caller if the sign (a)s menu was
invoked, which displayed the key selection menu. This is no longer
necessary with the menu stack pop operation.
Kevin McCarthy [Mon, 27 Mar 2017 01:31:41 +0000 (18:31 -0700)]
Set refresh when popping the menu stack.
This removes the need for the OPTNEEDREDRAW option and MAYBE_REDRAW
macro previously used to communicate back the need to refresh after
exiting a menu.
Remove the redraw parameter from ci_bounce_message() and
mix_make_chain() which served the same purpose.
Kevin McCarthy [Sun, 26 Mar 2017 19:27:15 +0000 (12:27 -0700)]
Fix mutt_refresh() pausing during macro events.
Changeset a07e8215a0ef split input buffering into two pools.
Unfortunately, the mutt_refresh() was not changed to check the correct
buffer count, resulting in unnecessary refreshes during macros.
The SSL interactive certificate prompts set OPTIGNOREMACROEVENTS and
then put up a confirmation menu. Perhaps we've just been lucky, but
it seems we should refresh the screen in those cases if we're in the
middle of a macro. Add a check for this option in mutt_refresh() too.
Kevin McCarthy [Mon, 20 Mar 2017 17:16:03 +0000 (10:16 -0700)]
Fix setenv overwriting to not truncate the envlist. (see #3922)
The refactor in 2b9c40f13e13 exposed a bug I hadn't noticed. The
match loop performed a FREE() on the slot. Then, below, it was
checking if (*envp) to see whether it was overwriting or creating a
new slot. However, FREE() nulls out *envp. This would end up
truncating the envlist just after the set slot!
Move the free down, using a mutt_str_replace(), when overwriting the
slot.
Kevin McCarthy [Sat, 18 Mar 2017 20:38:20 +0000 (13:38 -0700)]
Fix conststrings type mismatches. (closes #3926)
The generation programs for conststrings.c: txt2c.c and txt2c.sh,
specified the resultant types as "unsigned char[]" while main.c
declared them as "const char[]".
txt2.c generates 0xXX hex codes for each individual character, thus
the "unsigned" definition. With link-time optimization, some versions
of gcc notice the mismatch and emit a warning.
Change the declarations to match the definitions and cast to char[]
when they are used.
Add shortcuts for IMAP and POP mailboxes in the file browser
Mailbox list may not be properly displayed in a standard 80-column
terminal window if the $folder variable contains a long URL. In such
a case only left part of each entry name can be visible with the default
value of $folder_format. What's worse, this visible part may not be
enough to distinguish between the entries.
Thus in this case mutt_pretty_mailbox() will be just as useful as for
local mailboxes.
Kevin McCarthy [Thu, 9 Mar 2017 21:00:10 +0000 (13:00 -0800)]
Add SNI support for OpenSSL. (see #3923)
The original patch for this is by Phil Pennock at:
https://people.spodhuis.org/phil.pennock/software/mutt-patches/
I have removed the OpenSSL version check and defined(OPENSSL_NO_TLSEXT)
check because:
* SSL_set_tlsext_host_name() was added in 0.9.8f [11 Oct 2007]
* OpenSSL 1.1 no longer has the OPENSSL_NO_TLSEXT compilation option
* https://rt.openssl.org/Ticket/Display.html?id=2788&user=guest&pass=guest
shows that the no-tlsext compilation option has been broken for some time.
* Going forward, I'd like to minimize and start removing cruft required
to support ancient/insecure versions of libraries.
On a hostname mismatch, saving the certificate is pointless because
mutt will ask the user no matter if the certificate is saved or not.
The only invocation allowing "accept always" is guarded by a call to
check_certificate_digest(), which means the check_certificate_file()
check is redundant. Therefore remove that check and add a comment
noting why.
Thanks to Matthias Andree for the original version of this patch.
Kevin McCarthy [Thu, 9 Mar 2017 18:56:21 +0000 (10:56 -0800)]
Prevent skipped certs from showing a second time. (see #3916)
OpenSSL sometimes passes a skipped certificate to
ssl_verify_callback() a second time, with preverify_ok=1. From
OpenSSL's viewpoint there is nothing wrong with this, but mutt will
end up showing the certificate in the interactive prompt again.
Cache the last cert and position, and compare with the latest when
skip_mode and preverify_ok are both set.
Kevin McCarthy [Wed, 8 Mar 2017 02:26:06 +0000 (18:26 -0800)]
Move the OpenSSL partial chain support check inside configure.ac. (see #3916)
Instead of directly checking whether X509_V_FLAG_PARTIAL_CHAIN is
defined everywhere, do it once inside configure. This will allow
better support in the future if the test needs to change.
Matthias Andree [Wed, 8 Mar 2017 02:26:04 +0000 (18:26 -0800)]
Add $ssl_verify_partial_chains option for OpenSSL. (closes #3916)
The reworked OpenSSL certificate validation took away a "feature" of
the previous implementation: the ability to reject a node in the chain
and yet continue to the next node.
If this new option is set to 'yes', enables OpenSSL's
X509_V_FLAG_PARTIAL_CHAIN flag to reinstate the functionality and permit
to use a non-root certificate as the trust anchor.
This option is only available if OpenSSL offers the
X509_V_FLAG_PARTIAL_CHAIN macro, which should be the case as of 1.0.2b
or later.
Code written by Kevin McCarthy and Matthias Andree.
Kevin McCarthy [Sun, 5 Mar 2017 23:24:45 +0000 (15:24 -0800)]
Increase ACCOUNT.pass field size. (closes #3921)
#3921 reported his password token used for Google XOAUTH2 is size 129.
The ACCOUNT structure currently uses a size 128 buffer. Who knew a
password field would ever be bigger than that?
Since the ACCOUNT structure has no allocation/dellocation routines,
the easiest fix is to increase the size. Bump the size up to 256.