Richard Russon [Thu, 24 Nov 2016 14:02:48 +0000 (14:02 +0000)]
merge: hcache refactor
* Support compilation of multiple hcache backends and run-time selection
* More hcache-related cleanup and consistency in autoconf land
* Hcache backends list
* Hcache backends list up tidying
* Implement mutt_hcache_free to dispose of header cache data
Pietro Cerutti [Thu, 10 Nov 2016 13:33:16 +0000 (13:33 +0000)]
Support compilation of multiple hcache backends and run-time selection
Backend specific APIs have been moved to hcache-backend.h
This commits introduces the support for multiple backends and an option to
configure the one to use at run time (header_cache_backend). Backends are not
mutual exclusive anymore, and several can be compiled in by specifying multiple
--with-<backend> configure options.
For backwards compatibility, the header_cache_backend option can be left empty,
in which case the first (configure.ac order) compiled-in backend is selected.
In the case of distros building with a single backend enabled - as they are
forced to do today - the hcache functionality is unchanged.
Richard Russon [Sat, 19 Nov 2016 01:39:44 +0000 (01:39 +0000)]
merge: upstream adoption of compress
* Compress patch from the neomutt repository.
* Compress: prefix external functions with "mutt_"
* Compress: remove buffy stats "improvisation".
* Compress: fix several logic and memory bugs.
* Compress: add delegate calls to open_append and close mx_ops functions.
* Compress: safe_fopen() the tempfile, to prevent tempfile attacks.
* Compress: pull the lock/unlock operations into the open,close,sync operations.
* Create mx_ops.sync operation. Refactor compress to use the mx_ops.sync.
* Compress: fix check_mailbox and sync_mailbox.
* Compress: escape single quotes when invoking the compress/decompress commands.
* Compress: check mailbox type if possible when appending.
* Ensure the compressed documentation is always built.
* Improve two compress translation messages.
* Revert "Compress: remove buffy stats "improvisation"."
Kevin McCarthy [Mon, 14 Nov 2016 04:02:36 +0000 (20:02 -0800)]
Compress: check mailbox type if possible when appending.
If an append hook isn't defined, then mutt has to decompress the
mailbox. In that case, we can check the type of the decompressed
mailbox instead of defaulting to DefaultMagic.
Kevin McCarthy [Mon, 14 Nov 2016 04:02:35 +0000 (20:02 -0800)]
Compress: fix check_mailbox and sync_mailbox.
Change check_mailbox to delegate to the child_ops->check_mailbox if
the compressed mailbox has changed. This allows the mailbox to
properly recover if both the decompressed mailbox and compressed file
have changed.
Change sync_mailbox to call check_mailbox before attempting to sync.
This will prevent overwriting external changes to the compressed
mailbox.
Kevin McCarthy [Mon, 14 Nov 2016 04:02:35 +0000 (20:02 -0800)]
Create mx_ops.sync operation. Refactor compress to use the mx_ops.sync.
Change compress.sync_mailbox() to lock the compressed mailbox around
both the tempfile sync and compress operations. This will prevent
changes made inbetween the two syncs from being overwritten.
Thanks to Damien Riegel for his original patch refactoring
mx_ops.sync, which this patch is partially based upon.
Kevin McCarthy [Mon, 14 Nov 2016 04:02:35 +0000 (20:02 -0800)]
Compress: pull the lock/unlock operations into the open,close,sync operations.
Some operations, such as open_append and sync, need an exclusive lock
across a longer period than a single compress/decompress. Remove it
from the execute_command and pull into the outer callers. Store lock
information inside compress_info.
Sync and check_mailbox need more fixes, which will be addressed in
subsequent patches.
Kevin McCarthy [Mon, 14 Nov 2016 04:02:34 +0000 (20:02 -0800)]
Compress: add delegate calls to open_append and close mx_ops functions.
The open_append and close were partially duplicating mbox open_append
and close operations internally. Change it to call the actual
delegate functions instead.
Inline the open_read() function inside open_mailbox(). Having it
split improved nothing and just complicated the code (i.e. added
error-handling checks in open_mailbox() that in reality could not
fail).
Kevin McCarthy [Mon, 14 Nov 2016 04:02:34 +0000 (20:02 -0800)]
Compress: fix several logic and memory bugs.
setup_paths leaks memory: realpath is already set in mx_open_mailbox()
restore_paths is unneeded. mx_fastclose_mailbox() will free stuff,
and nothing is looking at the path once we are closing or aborting.
Make a copy of the hooks. Otherwise 'unhook *' will leave dangling
pointers.
Add compress_info freeing inside mx_fastclose_mailbox(). Only free
inside compress.c when we want to prevent close() from doing anything.
close_mailbox() didn't preserve ctx->path on error.
execute_command() didn't return an error if the mutt_system() command
failed.
mx_open_mailbox_append() should check mutt_comp_can_append() only for
the case that the mailbox doesn't exist. When it exists,
mx_get_magic() has already looked at the file contents before checking
for matching open_hooks.
In open_append_mailbox() if no append hook is defined, it should't
call ci->open() if the mailbox doesn't exist. It should act just like
append and create a temporary file.
check_mailbox() needs more work. For now, at least have it properly
close the mailbox on error.
Kevin McCarthy [Mon, 14 Nov 2016 04:02:34 +0000 (20:02 -0800)]
Compress: remove buffy stats "improvisation".
Mutt doesn't support polling compressed mailboxes. This code creates
a false impression and dirties mutt_save_message() in the process. I
don't like it, so am taking it out.
The mx_fastclose_mailbox() calls mx_ops->close(), which invokes
mbox_close_mailbox().
Also, close the ctx->fp inside mbox_close_mailbox(). This way, the
(to be added) compress logic can call the mx_ops->close() instead of
"knowing" to close the fp before recompressing.
mx_fastclose_mailbox() will safe_fclose() the fp again, but I'm
leaving it there just in case I missed a usage of the fp in some other
part of the code.
Kevin McCarthy [Tue, 8 Nov 2016 02:10:27 +0000 (18:10 -0800)]
Chain %d->%F->%f in the attachment menu.
Previously, %d would use %f if there was no description set.
Place the new %F option in between %d and %f. This way, %d will fall
back on %F, which will fall back on %f. This allows the standard
attachment menu to show d_filename.
This is useful for forwarding attachments or editing draft files with
attachments. In these cases the actual filename is sanitized but the
attachment name is preserved in d_filename.
Damien Riegel [Tue, 8 Nov 2016 02:10:22 +0000 (18:10 -0800)]
compose: add operation to rename an attachment
As opposed to rename-file, which actually renames the underlying file
of the attachment, rename-attachment puts a value in d_filename, which
is used in the Content-Disposition header.
Thomas Adam [Wed, 26 Oct 2016 22:58:16 +0000 (23:58 +0100)]
hooks: define hooks for startup and shutdown
Having hooks which run when mutt first starts (startup-hook) but before the
fist mbox is opened, and when mutt closes the mbox (shutdown-hook) before
exiting, allows for those notmuch users to run commands to sync the state of
their caches, etc.
support GLOBALHOOK type
There's now a few hooks (startup/shutdown/timeout) which don't operate on a
mbox or pattern, but are instead global to mutt. Therefore, don't require the
hooks themselves to needlessly define these parameters.
Pietro Cerutti [Sun, 13 Nov 2016 16:52:13 +0000 (16:52 +0000)]
build: Improve discovery for the Berkeley Database
- Drop support for old BDB versions and fix autoconf discovery
- Be more verbose when looking for BDB
- Hardcode a couple of commonly used prefixes
- Workaround empty path component expansion
- Do not clobber LIBS with BDB libraries
Richard Russon [Fri, 4 Nov 2016 14:59:07 +0000 (14:59 +0000)]
merge: upstream fixes (mutt/default)
* Add a --disable-doc configuration option.
* Make ncurses and ncursesw header checking the same.
* Attempt to silence a clang range warning. (closes #3891)
* Fixed issue from changeset 4da647a80c55. (closes #3892)
* Define PATH_MAX, it's missing on the GNU Hurd. (closes #3815)
Richard Russon [Fri, 28 Oct 2016 15:01:14 +0000 (16:01 +0100)]
merge: upstream fixes (mutt/default)
* Add root-message function to jump to root message in thread.
* Updated French translation.
* Prevent an integer overflow in mutt_mktime() (closes #3880)
* Fix pager segfault when lineInfo.chunks overflows. (closes #3888)
* Perform charset conversion on text attachments when piping. (closes #3773) (see #3886)
Kevin McCarthy [Sun, 23 Oct 2016 22:11:56 +0000 (15:11 -0700)]
Perform charset conversion on text attachments when piping. (closes #3773) (see #3886)
When piping a text attachment, there is no reliable way to know the
charset used.
Vincent Lefèvre says:
It was decided in the past that when there is no information on the
charset in a transmission to an external command (e.g. as for mail
composing), texts are expected to be transmitted in the local
charset.
Add a MUTT_CHARSET flag to enable charset conversion on text
attachments for both when $attach_split is set and unset.
Kevin McCarthy [Sun, 23 Oct 2016 21:46:37 +0000 (14:46 -0700)]
Fix pager segfault when lineInfo.chunks overflows. (closes #3888)
The reporter had an html attachment with extremely long lines,
combined with a color pattern of "color body default default ."
This overflowed the lineInfo.chunks, causing a segfault.
Kevin McCarthy [Wed, 19 Oct 2016 20:21:16 +0000 (13:21 -0700)]
Add root-message function to jump to root message in thread.
This seems like a useful feature that was brought up for discussion on
mutt-users. Proposed solutions involved collapsing/uncollapsing
threads, but it's not hard to modify the mutt_parent_message()
function to return the root instead.
Richard Russon [Fri, 28 Oct 2016 10:13:24 +0000 (11:13 +0100)]
merge: upstream fixes (mutt/default)
* Fix POP3 SASL authentication mechanism DIGEST-MD5. (closes #3862)
* Add a few explanatory comments to pop_auth_sasl(). (see #3862)
* Fix GPGME signature zero timestamp and locale awareness issues. (closes #3882)
* Handle presence of '--' delimiter in $sendmail. (closes #3168)
* Allow IPv6 literal addresses in URLs. (closes #3681)
* Fix gpgme segfault in create_recipient_set().
* Use mutt_strlen and mutt_strncmp in sidebar.c.
* Change sidebar to only match $folder prefix on a $sidebar_divider_char. (closes #3887)
* Actually fix gpgme segfault in create_recipient_set().
Kevin McCarthy [Mon, 17 Oct 2016 18:22:13 +0000 (11:22 -0700)]
Actually fix gpgme segfault in create_recipient_set().
Changeset 6e44bfa16096 did not fix the segv. (Sorry, I made the fix
based off a report on IRC but didn't trigger the segv myself: it was
caused by an out-of-tree patch).
The actual problem was that the rset was only resized on a successful
gpgme_get_key(). However, on error, the array still needs to be
NULL-terminated before calling free_recipient_set().
Move the resize so it always takes place. This obviates the need for
the NULL check added in 6e44bfa16096.
Kevin McCarthy [Sun, 16 Oct 2016 22:44:17 +0000 (15:44 -0700)]
Change sidebar to only match $folder prefix on a $sidebar_divider_char. (closes #3887)
The reporter had a $spoolfile of ~/Mailbox and a $folder of ~/Mail.
The sidebar was truncating the spoolfile to "ox" because it only
looked at a substring prefix match.
Kevin McCarthy [Sun, 16 Oct 2016 21:16:47 +0000 (14:16 -0700)]
Fix gpgme segfault in create_recipient_set().
If gpgme_get_key() errors on the first key, the rset will not be
allocated yet. Attempting to null-terminate (and then free) the array
causes a segfault.
Kevin McCarthy [Thu, 13 Oct 2016 01:10:35 +0000 (18:10 -0700)]
Handle presence of '--' delimiter in $sendmail. (closes #3168)
If the delimiter exists, additional sendmail flags will be inserted
before the delimiter. Any arguments after the delimiter will be
preserved as recipients.
Fix GPGME signature zero timestamp and locale awareness issues. (closes #3882)
GPGME signature information has two minor problems.
[-- Begin signature information --]
*BAD* signature from: Name <user@example.com>
aka: Name <user@example.org>
created: Thu Jan 1 09:00:00 1970
[-- End signature information --]
First, the created timestamp is incorrect when the message is not
verified successfully.
Second, as the code itself has some "TODO" comments, "aka" and
"created" lines are not properly-aligned when LC_MESSAGES != English.
sasl_client_step() returns SASL_OK after the fourth step: server auth
confirmation. However, the protocol requires the client send one more
blank line to the server, to which the server then replies with "+OK".
See https://tools.ietf.org/html/rfc5034#section-6.
The code currently only sends a final response if sasl_client_step
returns data to send. Change it to always send a final client message
after the SASL_OK.
Ismaël Bouya [Thu, 20 Oct 2016 12:37:47 +0000 (14:37 +0200)]
notmuch: Add a fake "Folder" header to viewed emails
When viewing an email from a virtual folder, you can't tell where the
real email lives. This commit adds a fake header, "Folder:" showing
that location.
Richard Russon [Sun, 23 Oct 2016 17:18:08 +0000 (18:18 +0100)]
Possible fix for random pager crashes.
The crashes have been observed:
- in both local and remote mailboxes
- with/without notmuch
- always are some time has passed
- always have an invalid header pointer
Scenario:
- The Context holds an array of HEADER pointers.
- The pager is given a HEADER to display.
- Time passes and the mailbox changes.
mx_check_mailbox() adds new mails to the end of the Context's array,
calling mx_alloc_memory() if necessary. The Context's totals are
updated by mx_update_context().
The only way a HEADER pointer could become invalid is if they email were
deleted/moved. If we detect this has happened, we leave the pager.