Richard Russon [Thu, 1 Jun 2017 18:38:57 +0000 (19:38 +0100)]
merge: upstream fixes (mutt/default)
* Convert classic s/mime to space delimit findKeys output.
* Add self-encrypt options for PGP and S/MIME.
* Change $postpone_encrypt to use self-encrypt variables first.
* automatic post-release commit for mutt-1.8.3
* Add note about message scoring and thread patterns. (see #3947)
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 [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.
Richard Russon [Thu, 25 May 2017 23:28:30 +0000 (00:28 +0100)]
merge: upstream fixes (mutt/default)
* Move the IMAP msn field to IMAP_HEADER_DATA. (see #3942)
* Fix imap expunge to match msn and fix index. (see #3942)
* Fix cmd_parse_fetch() to match against MSN. (see #3942)
* Start fixing imap_read_headers() to account for MSN gaps. (see #3942)
* Add msn_index and max_msn to find and check boundaries by MSN. (see #3942)
* Properly adjust fetch ranges when handling new mail. (see #3942)
* Small imap fetch fixes. (see #3942)
* Don't abort header cache evaluation when there is a hole. (see #3942)
* Fix mfc overflow check and uninitialized variable.
* Fix potential segv if mx_open_mailbox is passed an empty string. (closes #3945)
* Don't clean up idata when closing an open-append mailbox.
* Don't clean up msn idata when closing an open-append mailbox. (see #3942)
* Fix memory leak when closing mailbox and using the sidebar.
* Change imap body cache cleanup to use the uid_hash.
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 [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.
Richard Russon [Sat, 20 May 2017 14:05:34 +0000 (15:05 +0100)]
add names prototype arguments
Header files are easier to understand if the arguments are named.
e.g., replace:
int mutt_copy_stream(FILE *, FILE *);
with:
int mutt_copy_stream(FILE *fin, FILE *fout);
Richard Russon [Thu, 18 May 2017 14:06:30 +0000 (15:06 +0100)]
merge: upstream fixes (mutt/default)
* Turn IMAP_EXPUNGE_EXPECTED back off when syncing. (closes #3940).
* Add $history_remove_dups option to remove dups from history ring.
* Also remove duplicates from the history file.
* Don't filter new entries when compacting history save file.
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.
Richard Russon [Sat, 13 May 2017 13:13:22 +0000 (14:13 +0100)]
build: move configure-generated files
This small change moves 6 configure-generated files into a directory we
won't see (.build-aux)
compile
config.guess
config.sub
depcomp
install-sh
missing
Richard Russon [Sat, 13 May 2017 13:10:47 +0000 (14:10 +0100)]
build: update distcheck build flags
"make dist" creates a .tar of the source.
"make distcheck" does a complete build on that .tar
Make sure we have an up-to-date list of configure options.