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
Kevin McCarthy [Sun, 22 Sep 2019 01:34:51 +0000 (18:34 -0700)]
Fix mutt_save_message() "enter_fname()" to use buffer version
Commit be632f11 converted this function to use the buffer pool, but
accidentally used the non-buffer prompt when there was already a
buffer-converted version.
Kevin McCarthy [Mon, 2 Sep 2019 02:10:23 +0000 (19:10 -0700)]
Fix memory leak when attaching messages
Setting actx->idx[]->content->parts to NULL causes a memory leak,
because message attachments store a BODY there that needs to be freed.
I looked through the various use cases of ci_send_message() and
actually believe content->parts will be NULL for all other cases
except message attachments. From the comment added to
delete_attachment():
Other ci_send_message() message constructors are careful to free
any body->parts, removing depth:
- mutt_prepare_template() used by postponed, resent, and draft files
- mutt_copy_body() used by the recvattach menu and $forward_attachments.
I believe it is safe to completely remove the "content->parts =
NULL" statement. But for safety, am doing so only for the case
it must be avoided: message attachments.
Richard Russon [Tue, 1 Oct 2019 10:13:08 +0000 (11:13 +0100)]
merge: fix new mail behaviour
Fix a number of regressions to do with new mail.
* fix: mbox_check_stats() retvals
* fix mbox's handling of new mail
* fix <change-folder> when $change_folder_next is set
* fix sidebar colour for 'new' mailboxes
* change check_stats() to return number of new emails
Richard Russon [Mon, 30 Sep 2019 11:43:11 +0000 (12:43 +0100)]
merge: refactor use of curses
Tidy:
* eliminate curses from Progress Bar
* move colour definitions to color.h
* tidy naming of color functions
* move KeyEvent out of mutt_curses.h
Refactor:
* SET_COLOR() to mutt_curses_set_color()
* NORMAL_COLOR() to mutt_curses_set_color()
* ATTR_SET() to mutt_curses_set_attr()
* curs_set() to mutt_curses_set_cursor()
* beep() to mutt_beep()
* addch() to mutt_window_addch()
* addnstr() to mutt_window_addnstr()
* addstr() to mutt_window_addstr()
* clrtobot() to mutt_window_clrtobot()
* move() to mutt_window_move_abs()
* printw() to mutt_window_printf()
* mutt_window_mvaddstr()
* clearok() to mutt_window_clear_screen()
* mutt_window_getxy() to mutt_window_get_coords()
Richard Russon [Fri, 27 Sep 2019 15:03:52 +0000 (16:03 +0100)]
refactor: move() to mutt_window_move_abs()
Encapsulate a curses function to reduce dependencies.
This function works with absolute screen coordinates rather than coords
based on a MuttWindow. This function should be eliminated soon.