Kevin McCarthy [Fri, 4 Jan 2019 03:58:18 +0000 (19:58 -0800)]
Clean up code indentation.
These are mostly automated changes corresponding to the emacs
settings:
(c-set-style "linux")
(setq c-basic-offset 2)
(c-set-offset 'case-label '+)
Most of the code follows the convention:
(add-to-list 'c-cleanup-list 'space-before-funcall)
but this is not enforced by this indentation cleanup.
Also, I personally dislike tabs, so I have:
(setq-default indent-tabs-mode nil)
in my own configuration. However I have no desire to change every line
just for that effect. So this cleanup does nothing about the mix issue.
Some of the secondary files (e.g. regex.c) have been skipped.
I've also skipped crypt-gpgme.c, because I need to think about that
file. Werner Koch and the GnuPG team contributed most it, and it
follows the Gnu indentation settings. It should probably be made
uniform with Mutt, but I don't want to discourage future GnuPG
contribution to the file.
I manually reverted a few unsightly cleanups, and added a few tweeks
when I saw things that could be improved.
Kevin McCarthy [Fri, 4 Jan 2019 19:20:05 +0000 (11:20 -0800)]
Fix mkdtemp.c implementation.
Two statements were indented on the same line under a for statement.
The second one would not be included in the loop, only being executed
after the loop finishes.
This is obviously an error, as it modifies the LETTERS entry being
used.
Kevin McCarthy [Mon, 31 Dec 2018 22:19:44 +0000 (14:19 -0800)]
Remove dead code.
Most of these have been "#if 0" out for 10-20 years. Any utility in
keeping them around is miniscule at this point.
There are a few other "#if 0" in the code, but I've kept them for now.
Some are utility functions that are not used, but I think still may
have some documentation value.
Kevin McCarthy [Thu, 27 Dec 2018 20:05:43 +0000 (12:05 -0800)]
Add $crypt_protected_headers_save.
Setting this option will save the protected header back into the
clear-text message headers. This improves
usability (searching/limiting/replying) when reopening a mailbox
without header cache. However, it is a security trade-off, so
defaults off and strongly warns about what it is doing in the documentation.
Kevin McCarthy [Wed, 26 Dec 2018 03:52:53 +0000 (19:52 -0800)]
Change x-label editing flag to be in the envelope.
Handle like In-Reply-To and References editing. Change the flag
setting to be inside mutt_copy_header().
The resetting of the changed flag occurs explicitly in the imap and
maildir/mh sync_mailbox code. It occurs for mbox in the
mx_update_tables() call in mx_sync_mailbox().
Kevin McCarthy [Wed, 26 Dec 2018 03:24:08 +0000 (19:24 -0800)]
Create envelope->changed to mark all field changes.
In subsequent commits, we're going to add the x-label and subject
headers changed flags into the envelope. To avoid the list of checks
exploding everywhere, just use a single field to check and reset those
values.
Several places in the code are checking for a null header->env. I
wasn't aware this was possible, so I've added todo notes to track down
when this occurs.
Vincent Lefevre [Sat, 29 Dec 2018 18:37:57 +0000 (19:37 +0100)]
Added support for the "light" color prefix (in addition to "bright").
At the same time, restrict the advance by 8 to colors in the range 0-7
and no longer use the blink attribute to emulate light background colors
in some terminals (e.g. linux console and rxvt), as this is really blink
in other terminals (e.g. xterm); light background colors can still be
obtained by choosing a proper $TERM value (tested with linux console,
using TERM=linux-16color, and rxvt).
Kevin McCarthy [Fri, 28 Dec 2018 23:43:51 +0000 (15:43 -0800)]
Make a copy of x_label before encoding it for updates.
This isn't actually a bug. Context->label_hash strdups the keys, so
we are safe from dangling references. However, the subj_hash uses
direct references, so to keep things consistent and safe, make a copy
and encode that.
Kevin McCarthy [Fri, 28 Dec 2018 00:24:27 +0000 (16:24 -0800)]
Restore the xlabel_changed reset.
The cherry pick accidentally obliterated the reset. That flag is now
located in hdr->env->changed in the branch and is reset properly
elsewhere. Keep it in place in the stable branch.
Some clients (or even mail servers) improperly encode the octetstream
part.
Thanks to Riccardo Schirone for the original merge request patch.
This commit also handles the attachment menu, and makes the decoding
conditional so it's not done if it isn't necessary.
Some clients (or even mail servers) improperly encode the octetstream
part.
Thanks to Riccardo Schirone for the original merge request patch.
This commit also handles the attachment menu, and makes the decoding
conditional so it's not done if it isn't necessary.
Kevin McCarthy [Fri, 21 Dec 2018 17:42:26 +0000 (09:42 -0800)]
Display mail sent message after Fcc finishes.
For the case of IMAP, the uploading message would otherwise stay on
the screen. In any case, it's best to show that message as the last
thing before returning to the index.
Kevin McCarthy [Thu, 20 Dec 2018 01:43:26 +0000 (17:43 -0800)]
When postponing, encode descriptions before encrypting.
This matches the behavior of the normal send process. I don't think
there is actually an issue here since nothing is sent, but it makes
sense to be consistent.
Kevin McCarthy [Thu, 13 Dec 2018 00:10:23 +0000 (16:10 -0800)]
Fix imap_sync_mailbox() hcache leak.
Uploading changed messages to the server ends up overwriting the
hcache. Add a straightforward fix and a longish explanation comment
for the stable branch fix.
Add a TODO noting a better fix should be done in the master branch in
the future.
Kevin McCarthy [Fri, 7 Dec 2018 03:22:59 +0000 (19:22 -0800)]
Fix classic gpg date parsing in list-keys.
GnuPG changed the format of their --with-colons output in 2.0.10.
Dates are now seconds since epoch. Update the parse_pub_line() code
to detect the new format.
The GnuPG changes also separated pub and the first uid. Since mutt
allows an empty uid field, the output is a bit less friendly now, with
an initial key without an uid. I think that's acceptable, but
eventually we'll want to change the parsing behavior.
The latter commit also introduced a bug in the import code which
listed all keys in the keyring to a temporary file and copied that one
to stdout. The former commit avoided the output to stdout.
The fix here is to use pgp_gpgme_extract_keys only for extracting
information about the key and don't re-use the same code for importing
keys. We now import the keys directly in pgp_gpgme_invoke_import and
we print the fingerprint and status flags for all imported keys. That
information available from GPGME for ages (0.3.1 from 2003).
The user id is unfortunately not printed; that would require a lookup
of the newly imported key. Can be done with another patch.
Werner Koch [Mon, 3 Dec 2018 07:41:55 +0000 (08:41 +0100)]
Try to avoid creation of temp. directory for key import.
Since gpgme 1.9.0 it is possible to list keys directly from a file
without importing it into gpg' own keyring. This patch implements
this in a backward compatible way.
Unfortunately we need to check for a suitable gpgme version at build
time and also for a suitable gpg version at runtime. This is
implemented by a version check which requires to call or include code
taken from libgpg-error (aka gpgrt). However this library is anyway a
dependency of gpgme and thus does not pose any extra burden.
The functions parse_version_number, parse_version_string, and
cmp_version_strings are taken from libgpg-error's repo at 2018-11-20.
Libgpg-error is distributed under the LGPL-2.1-or-later.
Werner Koch [Mon, 3 Dec 2018 07:41:54 +0000 (08:41 +0100)]
Always use the gpgme_new wrapper in crypt-gpgme.
The wrapper is much more convenient and there is no need to sometimes
use gpgme_new directly. The perceived advantage on not bailing out in
an out-of-core condition is not realistic because other small amounts
of memory are allocated all over mutt anyway and thus function will
terminate the process as well.
This patch also changes the minimum version of gpgme to 1.4.0. This
is so that we can always pass NULL to functions like gpgme_release.
Further 1.4.0 has new functions which we may soon like to use.
Werner Koch [Mon, 3 Dec 2018 07:41:53 +0000 (08:41 +0100)]
Require GPGME version 1.2.0 and drop useless HAVE macros.
GPGME 1.2.0 was released nearly 10 years ago and thus we can really
demand this version. For various reasons it would be advisable to
require a decent version but that is a different thing and needs to be
done in a separate patch.
HAVE_GPGME_OP_EXPORT_KEYS and HAVE_GPGME_PKA_TRUST are not anymore
needed because they are supported by that GPGME version.
Kevin McCarthy [Mon, 3 Dec 2018 05:39:55 +0000 (21:39 -0800)]
Improve rfc2047_decode to deal with improperly split words.
Some non-compliant MUAs split rfc2047 words inside a multibyte
character.
Deal with this by accumulating decoded words sharing the same
character set, and then perform character conversion all at once.
It is not clear to me that the $ignore_linear_white_space option is
functional or properly coded, but I've gone through the effort of
trying to preserve its calls.
Kevin McCarthy [Thu, 29 Nov 2018 20:36:08 +0000 (12:36 -0800)]
Add SENDER to default list of IMAP headers.
This header is matched by the ~e and ~L patterns. Those patterns
should work without the user having to know to add Sender to the list
of $imap_headers. This was probably just an oversight.
Kevin McCarthy [Thu, 29 Nov 2018 20:36:08 +0000 (12:36 -0800)]
Add SENDER to default list of IMAP headers.
This header is matched by the ~e and ~L patterns. Those patterns
should work without the user having to know to add Sender to the list
of $imap_headers. This was probably just an oversight.
Kevin McCarthy [Tue, 27 Nov 2018 21:55:04 +0000 (13:55 -0800)]
Fix QRESYNC crash after a large number of VANISHED messages.
When handling QRESYNC vanished, imap_expunge_mailbox() was called to
empty out the messages. Various counters, including vcount are
updated by the mx_update_tables() after the expunge.
These counters need to be reset, because mx_update_context() will do
so once again at the end of reading new headers. This can cause an
out of bounds access in v2r.
Kevin McCarthy [Mon, 26 Nov 2018 03:48:49 +0000 (19:48 -0800)]
Prevent trying to match a failing color body regex repeatedly.
Emails with really long lines (e.g. spam), can suffer performance if a
complicated regex is matched to no effect over and over. If the regex
failed at the beginning, it won't match at the end of another's regex
match range, so turn it off.
Kevin McCarthy [Mon, 19 Nov 2018 03:13:20 +0000 (19:13 -0800)]
Switch color chunk matching to use bsearch.
Emails with extremely long lines, combined with a large number of
color matches, can cause a performance hit so severe that mutt appears
to have hung.
Switching out to using a binary search speeds things up noticably.
The for loops being replaced were a bit strange. resolve_types()
ensures there are no overlaps, and that they are ordered. A match is
defined by (first <= cnt < last). I can't see any reason for the
strange comparison of (cnt > last) follow by (cnt != last). Perhaps
at one time it made sense.