Kevin McCarthy [Wed, 14 Jun 2017 22:12:45 +0000 (15:12 -0700)]
Enable all header fields in the compose menu to be translated.
While it is suggested they need not be, for some locales it might be
preferable to be able to localize the fields.
For instance, fr_FR may want to change the punctuation to have a space
in front of the colon. ja_JP may be more comfortable with a native
character set description of the field when using it every day.
Kevin McCarthy [Tue, 13 Jun 2017 01:29:48 +0000 (18:29 -0700)]
Force hard redraw after $sendmail instead of calling mutt_endwin. (closes #3952) (see #3948)
Adding a mutt_endwin() seemed like a clean solution to allowing
ncurses pinentry for $sendmail, but it leaves other users watching a
blank screen. This change is extremely likely to generate a large
number of complaints and bug reports. So instead, force a hard
refresh afterwards.
Vincent expressed some legitimate concerns about exporting this to all
programs lauched by mutt. The user can always set GPG_TTY in their
.bashrc if needed for $sendmail. cf90bf5989f3 should resolve the
refresh issue.
Kevin McCarthy [Wed, 7 Jun 2017 01:38:47 +0000 (18:38 -0700)]
Add a mutt_endwin() before invoking $sendmail. (closes #3948)
This is to support invoking a program such as msmtp that can use gpg
to decrypt a password. The ncurses pinentry can corrupt the screen
unless we exit curses.
Kevin McCarthy [Thu, 1 Jun 2017 22:17:01 +0000 (15:17 -0700)]
Change km_dokey() to return -2 on a timeout/sigwinch.
In some cases, such as tag-prefix or _mutt_enter_string(), it is
desirable to be able to distinguish between a timeout/sigwinch event
and an input error/abort/ctrl-g.
Kevin McCarthy [Wed, 31 May 2017 23:18:29 +0000 (16:18 -0700)]
Add note about message scoring and thread patterns. (see #3947)
Because scoring occurs before the mailbox is sorted, thread patterns
don't work. Document a suggested workaround of pushing the score
command in a folder hook.
Also, fix the link target for the score command synopsis.
Kevin McCarthy [Mon, 29 May 2017 18:48:43 +0000 (11:48 -0700)]
Change $postpone_encrypt to use self-encrypt variables first.
The concept of postpone encryption is similar to self-encrypting on
send. The problem is the $postpone_encrypt_as option doesn't take
into account whether PGP or S/MIME is being used.
Since we need to add the new options for self-encryption, modify
$postpone_encrypt to use them by default instead, falling back to
$postpone_encrypt_as if they are unset. Note $postpone_encrypt_as is
deprecated in the documentation.
$pgp_sign_as and $smime_default_key are inappropriate to use, as they
specify signing key/certs. In some cases, this is a different value
than the encryption key/cert.
Kevin McCarthy [Mon, 29 May 2017 18:48:41 +0000 (11:48 -0700)]
Convert classic s/mime to space delimit findKeys output.
Unlike gpgme and classic pgp, smime used a "cert\ncert\n" pattern.
Convert to use a space-delimited format, so the self-encrypt option
code can be uniform across pgp, s/mime, and gpgme.
Kevin McCarthy [Tue, 23 May 2017 22:53:30 +0000 (15:53 -0700)]
Fix memory leak when closing mailbox and using the sidebar.
The code updating the sidebar counts decremented the msgcount, but did
not set it back to the original value. Which means fastclose was not
freeing all the headers.
Update the sidebar only when something is deleted, since I don't
believe it's required otherwise and the code is a bit cleaner that
way.
Kevin McCarthy [Mon, 22 May 2017 11:43:24 +0000 (04:43 -0700)]
Fix mfc overflow check and uninitialized variable.
The check borrowed from mx_alloc_memory() works because it is
incremented 25 at a time. I don't believe it will work for the direct
set case used in imap_alloc_msn_index(). Instead, use a more
conservative check.
In imap_read_headers(), make sure mfhrc is initialized. It would be
tested without being set if imap_cmd_step() returned OK right away.
Kevin McCarthy [Mon, 22 May 2017 01:45:08 +0000 (18:45 -0700)]
Small imap fetch fixes. (see #3942)
Add an integer overflow test, pulled from mx_alloc_memory(), since the
count comes from a potentially hostile server.
After reviewing the RFC a bit, it turns out the server is not supposed
to send EXPUNGE responses during a FETCH. Change the comment, but
keep the conservative code.
Kevin McCarthy [Sun, 21 May 2017 17:51:38 +0000 (10:51 -0700)]
Properly adjust fetch ranges when handling new mail. (see #3942)
When pulling down headers, it is possible for expunge responses to
happen too. If we get a new mail count, we need to take into account
changes to the max_msn due to the expunges.
Kevin McCarthy [Sun, 21 May 2017 01:52:18 +0000 (18:52 -0700)]
Add msn_index and max_msn to find and check boundaries by MSN. (see #3942)
Since there can be gaps in MSNs, the largest MSN in the context is not
necessarily ctx->msgcount.
Use max_msn instead of ctx->msgcount for:
- the starting MSN of new mail header fetching
- boundary checking in fetch, expunge, and other places
Use msn_index to efficiently look up headers by MSN. This makes the
expunge code slightly more efficient. It also makes FETCH handling, and
duplicate FETCH FLAG handling efficient.
Kevin McCarthy [Sun, 21 May 2017 01:52:16 +0000 (18:52 -0700)]
Start fixing imap_read_headers() to account for MSN gaps. (see #3942)
Change the parameters to pass MSN instead of index, to make a bit
simpler.
Change header cache evaluation to look at the largest MSN retrieved
instead of ctx->msgcount for the next fetch start point. This still
depends on the assumption that MSNs are retrieved in ascending order,
which needs to be fixed.
Simplify the header cache inner loop termination and memory cleanup
logic. Fix a memory leak if a hole in the header cache occured.
Fix the header retrieval logic to take into account MSN gaps in the
results. Loop only as long as we get IMAP_CMD_CONTINUE instead of
over a fixed count. Simplify the inner loop termination and memory
cleanup logic too.
Simplify the "new mail while fetching" logic by creating a third outer
loop to handle re-fetches.
Fix msg_fetch_header() to return -2 if msg_parse_fetch() encounters a
corrupt FETCH response. Previously it would pass on the rc of
msg_parse_fetch(), meaning it would return -1 even though the response
was corrupt.
Kevin McCarthy [Sun, 21 May 2017 01:52:13 +0000 (18:52 -0700)]
Fix imap expunge to match msn and fix index. (see #3942)
The expunge needs to match against the MSN now. Since
cmd_parse_expunge() does not automatically fix h->index anymore,
change imap_expunge_mailbox() to fix up the h->index values.
Kevin McCarthy [Sun, 21 May 2017 01:52:12 +0000 (18:52 -0700)]
Move the IMAP msn field to IMAP_HEADER_DATA. (see #3942)
Ticket 3942 revealed that it is possible for a FETCH to have gaps in
the MSN numbers of the results. The code makes many assumptions that
equate context index counts and MSN. This is the first in a series of
commits fixing that assumption.
The header->index field is supposed to hold the SORT_ORDER index
number of the message. If there are gaps in the MSN, than the highext
MSN can in fact be out of the range 0..ctx->msgcount-1.
After studying the code, I believe curs_main.c would actually work
with header->index values out of the range, at least for IMAP. But
some other parts of the code, such as mutt_reopen_mailbox(), do rely
on the values being a valid index to ctx->hdrs[]. And the
intertwining of menu->oldcurrent with header->index values makes me
nervous about future changes.
So, to be safe, move the MSN to its own field in IMAP_HEADER_DATA.
Kevin McCarthy [Sat, 13 May 2017 16:48:28 +0000 (09:48 -0700)]
Don't filter new entries when compacting history save file.
If new entries are added between the two passes, they won't be in the
dup_hash. The original intent was to filter added duplicates, but the
check would also filter brand new entries.
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.