Kevin McCarthy [Wed, 16 Oct 2019 07:42:54 +0000 (15:42 +0800)]
Convert pgp_app_handler to use buffer pool
Rename the pgp_copy_checksig() and mutt_wait_filter() return code
variables to provide more clarity, and to make the purpose and
assignment of rc more obvious.
Change tmpfname creation failure to be like pgpoutfile and
pgperrfile, by going to the cleanup point.
Kevin McCarthy [Wed, 9 Oct 2019 04:59:41 +0000 (12:59 +0800)]
Convert main() to use buffers for paths
Convert fpath(used for checking and creating $folder).
Convert expanded_infile and tempfile which are used for the -i,-H, and
-E options. We allocate buffers, rather than use the pool, because
they are used for the duration of the compose/send operation.
Kevin McCarthy [Sun, 6 Oct 2019 05:37:14 +0000 (13:37 +0800)]
Convert mutt_parse_hook() to use buffer pool
Remove the path variable, as this is not needed:
mutt_buffer_expand_path() and mutt_check_simple() can operate directly
on the pattern/command buffers.
Austin Ray [Sat, 26 Oct 2019 02:55:39 +0000 (22:55 -0400)]
fix: abort entire-thread if database lacks message
If the notmuch database is missing a message, abort <entire-thread>
before causing a segfault. When <entire-thread> executes on a message
missing from the database, it segfaults. This happens because the
vfolder returned is empty and not in an properly initialized state for
the notmuch-backend. As such, the notmuch-backend segfaults.
To prevent a segfault, display a warning and pre-maturely exit
<entire-thread>. While the user is left in an empty vfolder, this is
consistent behavior for <entire-thread>. Ordinarily, you're left with
just the notmuch thread, which doesn't exist in this case.
The location of the abort is perfect for adding behavior to handle the
missing message. In the future, we can automatically run 'notmuch new'
after encountering a missing message. That is outside the scope of this
commit.
Richard Russon [Wed, 23 Oct 2019 10:41:16 +0000 (11:41 +0100)]
merge: eliminate uses of MuttIndexWindow
* eliminate MuttIndexWindow from mutt_copy_message()
* eliminate MuttIndexWindow from deep functions
* eliminate MuttIndexWindow from mutt_make_string_flags()
* eliminate MuttIndexWindow from Mixmaster
* eliminate MuttIndexWindow from mutt_display_message()
Richard Russon [Mon, 21 Oct 2019 11:34:04 +0000 (12:34 +0100)]
eliminate MuttIndexWindow from mutt_make_string_flags()
`mutt_make_string_flags()`, and its macro wrapper `mutt_make_string()`,
use `mutt_expando_format()` and `index_format_str()` to expand strings.
Some of the callers expect the string to be truncated at the screen
width. These functions now have an extra paramter to avoid using
`MuttIndexWindow` directly.
Richard Russon [Wed, 2 Oct 2019 22:58:39 +0000 (23:58 +0100)]
fix read-only mbox
If an mbox Mailbox doesn't have write privs, try opening it read-only.
Before the architectural changes, there could be multiple open Mailbox
objects representing a single folder.
By default a folder would be given a read-only Mailbox. When the folder
needed to be written to, another Mailbox would be opened read-write.
This lead to synchronisation problems between the two Mailboxes.
Beck, Andre [Fri, 11 Oct 2019 11:17:58 +0000 (19:17 +0800)]
Clear connection input buffer when closing
An RFC-violating reply from the Dovecot SMTP submission service
uncovered a bug in Mutt. Mutt was not clearing out the input buffer
when closing the connection.
Dovecot was including an extra 250 response after data submission:
DATA
354 OK
Subject: Test 3
Test 3
.
250 2.0.0 223 byte chunk, total 223
250 2.0.0 OK id=1iIqT1-0004wS-Ac
quit
221 2.0.0 Bye
The multiline 250 reply requires a hyphen in the first response. Mutt
closes the connection after the quit, but ends up leaving the
unexpected second line in the input buffer. This causes an error in
the next usage of the connection.
Clean out bufpos and available when closing the socket.
Darren Kenny [Mon, 2 Sep 2019 11:34:26 +0000 (12:34 +0100)]
Add ability to limit levels hidden with toggle-quoted command
Closes: #1802
By setting the configuration variable `toggle_quoted_show_levels`, when you
execute the `toggle-quoted` command, the specified number of levels
will continue to be visible.
Richard Russon [Tue, 8 Oct 2019 22:34:59 +0000 (23:34 +0100)]
merge: upstream refactoring
* Re-enable and cleanup format-flowed space stuffing
* Remove manual note about space-stuffing only once
* Reuse the static space_stuff function for unstuffing
* Convert crypt-gpgme to use struct Buffer for tempfiles
* Convert crypt_extract_keys and signed handler to use buffers
* Convert edit_one_message() to use buffer pool
* Convert run_decode_and_handler() to use buffer pool
* Convert hcache db4 lockfile to buffer
* Convert hcache_open to use buffer pool
* Fix built-in pager checks for help and attachments
* Convert mutt_edit_headers() to use buffer pool
* Convert mutt_help() to use buffer for tempfile
* Convert save-hook and fcc-hook to use buffer pool internally
* Fix mutt_write_mime_body() application/pgp-encrypted handling
* Convert imap_open_new_message() to use buffer pool
* Convert imap fetch_new and fetch_message tempfiles to buffer pool
* Convert imap_cachepath() and callers to use buffers
* Convert parse_path_(un)list to use buffer pool for path
* Convert start_debug() to use buffer pool
It would blindly overwrite any attachment with that type, as if it
were the version label part of a multipart/encrypted message.
However attachments with extenstion .gpg are labeled that type if
$mime_type_query_command is set to "xdg-mime query filetype". This
would cause the attachment to be overwritten too.
Add a check for a missing body->filename, which should only be the
case for the manually constructed part.
Kevin McCarthy [Wed, 25 Sep 2019 22:28:30 +0000 (15:28 -0700)]
Convert crypt-gpgme to use struct Buffer for tempfiles
Use the pool where possible, but when the function calls other
long-running functions (such as mutt_body_handler() or
mutt_do_pager()), allocate the buffer.
smime_gpgme_decrypt_mime() was not freeing the "cur" struct Body generated on
error. Add a call to mutt_free_body(cur) in the error handling.
Kevin McCarthy [Sat, 31 Aug 2019 20:37:16 +0000 (13:37 -0700)]
Re-enable and cleanup format-flowed space stuffing
Commit 04cb5bde tried to fix re-stuffing a postponed message more than
once, but unfortunately broke the normal case of composing a new
message. So actually, space-stuffing has been turned off the past 7
years.
Move format=flowed parameter setting below the standard message
pre-processing block. It shouldn't be performed for draft-files even
with $resume_draft_files set. Moving out of the block makes that
clearer.
Create mutt_rfc3676_space_(un)stuff() functions, which check the
content type and stuff/unstuff apprpropriately. Note that the
stuff/unstuff does not depend on $text_flowed, which is only in charge
of setting the format=flowed parameter. This parameter can also come
from resumed/resent/draft messages and should still be respected.
Add unstuffing to mutt_prepare_template(). This is called by
postponed, resent, and draft files. This will prevent double-stuffing
in those cases.
Unstuff/restuff around editing the message in the compose menu, to
keep everything transparent to the user. I originally put the
stuffing *after* the compose menu, but previewing the messages in the
compose menu did not work properly in that case. It's cleaner this
way too.
Change the stuff/unstuff functions to preserve the original
hdr->content->filename. The "hack" previously used would interact
poorly with editable body files (mutt -i -E). Fortunately space
stuffing was pretty much disabled except in unusual cases before.
Richard Russon [Mon, 7 Oct 2019 12:07:26 +0000 (13:07 +0100)]
fix: broken index_format
A chance alignment made enum symbol MT_COLOR_INDEX_NUMBER equal to 37
(ASCII %). This was causing problems when inserting colour codes into
the index_format string.
Richard Russon [Tue, 1 Oct 2019 10:48:33 +0000 (11:48 +0100)]
merge: upstream refactoring
* Properly revert on an autocrypt postpone failure
* Fix memory leak when attaching messages
* Convert bcache to use buffer pools
* Convert mutt_complete() to use the buffer pool
* Convert compose check_attachments() to use buffer pool
* Fix mutt_save_message() "enter_fname()" to use buffer version
* Create mutt_buffer_get_field()
* Convert buffer callers of mutt_get_field() to use buffer version
* Convert compose menu fname variable to buffer
* Convert compress setup_paths() to use buffer
* Fix memory leak in compose write-fcc function
* buffer: tidy checks for empty Buffers