Kevin McCarthy [Sat, 2 Feb 2019 23:03:03 +0000 (15:03 -0800)]
Separate out op variable in the browser.
The i variable is used in several places and scopes as a temporary
index variable, but is also used to record the current operation.
Separate them out to make the code less confusing.
Corey Minyard [Thu, 31 Jan 2019 23:57:57 +0000 (17:57 -0600)]
Allow descending into maildir and mh directories in file browser
Some (maybe most) IMAP mail systems allow folders to be nested inside
folders, so you can have, say, an Inbox with more folders inside it.
However, in the file browser, mutt will only open a maildir/mh
directory as a mailbox, there is no way to get to the child mailboxes.
This change adds a function <descend-directory> that forces mutt to
descend into the directory. It is unbound by default.
Kevin McCarthy [Fri, 25 Jan 2019 02:28:27 +0000 (18:28 -0800)]
Show top-level decoded smime text/plain parts.
Commit 331d9d5a attempted to fix a problem with an attachment having
extension .p7m. The attachment menu tried to decode and failed, and
the part ended up being replaced by a bogus text/plain part.
The problem is that crypt_smime_decrypt_mime() returns a text/plain
part if the decode fails, meaning we can't distinguish failure from
success in this case.
As a compromise, only use a text/plain resulting from a single
top-level application_smime part. This will allow for the case of an
text/plain encoded email, but won't end up hiding attachments that
were not decoded.
Kevin McCarthy [Thu, 24 Jan 2019 23:19:36 +0000 (15:19 -0800)]
Simplify nested smime handling in the attachment menu.
Since changeset 2fd6f99b allows nested encryption handling, there is
no need to deal with the nesting directly. Instead, just recursive as
with other nested handling.
Kevin McCarthy [Thu, 24 Jan 2019 22:15:33 +0000 (14:15 -0800)]
Improve attachment menu for s/mime parts. (closes #113)
Don't prompt for passphrase or getkeys, or set the ENCRYPT flag, for
OPAQUE types.
Don't recurse on "text" output from decrypt_mime(). There is no
reason to recurse on a text type. Additionally, the
mutt_read_mime_header() will return an empty text type even if the
decode doesn't generate mime output. In those cases, we want to show
the original attachment.
Kevin McCarthy [Tue, 22 Jan 2019 03:43:08 +0000 (19:43 -0800)]
Fix tunnels to also retry and write full buffer.
Change the tunnel_socket_read() and tunnel_socket_write() as the raw
sockets were adjusted in the previous commit. Retry on EINTR, and
complete a full write so all the implementations have the same behavior.
Kevin McCarthy [Mon, 21 Jan 2019 23:19:08 +0000 (15:19 -0800)]
Fix raw socket read/write to follow expected behavior.
The mutt_sasl.c code expects conn_write() to write the entire buffer.
This is inconsistent with mutt_socket.c, but since other conn_write()
implementations guarantee this, change raw_socket_write() to do so too
for now.
Also, update reading and writing to loop on EINTR, as gnutls does.
They won't return EAGAIN or EWOULDBLOCK because we don't mark sockets
as non-blocking.
Kevin McCarthy [Mon, 21 Jan 2019 19:56:04 +0000 (11:56 -0800)]
Fix gnutls tls_socket_write() to properly retry.
Retry on GNUTLS_E_AGAIN and GNUTLS_E_INTERRUPTED. This prevents an
aborted send due to a SIGWINCH, for instance.
Change tls_socket_read() to follow the same flow. Don't bother
checking gnutls_error_is_fatal() because return codes besides AGAIN
and INTERRUPTED end up closing the connection regardless. (We don't
handle handshakes and negotations during send/receive).
Kevin McCarthy [Thu, 10 Jan 2019 17:56:41 +0000 (09:56 -0800)]
Wrap ssl init calls for LibreSSL too.
It looks like LibreSSL does not perform automatic initialization of
the library and error strings.
Since LibreSSL defines OPENSSL_VERSION_NUMBER as a "version 2",
add a check if LIBRESSL_VERSION_NUMBER is defined and call the
initialization functions for that case.
Fabian Groffen [Thu, 10 Jan 2019 15:03:02 +0000 (16:03 +0100)]
mx_open_mailbox: provide output buffer to realpath(3)
Starting with POSIX.1.2008 resolved_path can be NULL.
Systems implementing a standard before that crash. Example of such
system is Mac OS X 10.5, the last version running on PowerPC hardware.
Since this is the only occurrance of the realpath(3) function in Mutt,
instead of wrapping it, just adjust this invocation.
Eike Rathke [Sat, 5 Jan 2019 21:54:26 +0000 (22:54 +0100)]
Fix mkdtemp() random signedness
time_t return of time() may be signed 32-bit and in that case
probably will roll over in the year 2038 and yield a negative
value; signedness was propagated in the XOR operation to the
'value' and then 'v' variables. The 'v % 62' operation then would
had resulted in a negative value and LETTER[v%62] would had
accessed an arbitrary data location.
The same could had happened if the static long 'value' variable
after a very long run time contained a sufficiently large value to
which the time^pid value added resulted in a wrap / roll-over to a
negative value.
Using unsigned long types for 'value' and 'v' and casting time_t
to unsigned long cures all this.
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.