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.
Richard Russon [Sat, 21 Sep 2019 17:15:03 +0000 (18:15 +0100)]
merge: fix coverity defects
* config: expand flags typedef
* fix Slist usage
* nntp: check pointers
* fix pointer checks in generate_body()
* fix leak in imap_parse_path()
* fix leak in mutt_attach_mail_sender()
* fix pointer checks in rfc2047_decode()
* check the buffer in enriched_putwc()
* fix var type in text_enriched_handler()
* check retval of mutt_str_atoui()
* check the buffer in enriched_puts()
* ensure that the buffer always exists in mutt_buffer_alloc()