Richard Russon [Fri, 1 Sep 2017 12:45:23 +0000 (13:45 +0100)]
merge: upstream fixes (mutt/default)
* Create ATTACH_CONTEXT to hold attachment index. (see #3728)
* Change helpers functions to pass actx. (see #3728)
* Add helpers to add and remove actx entries. (see #3728)
* Change recvattach to allow nested encryption. (see #3728)
* Add virtual index to actx. (see #3728)
* Fix the expand/collapse code to use the virtual index. (see #3728)
* Fix shared attachment functions. (see #3728)
* Fix attachment check_traditional and extract_keys operations. (see #3728)
* Add edit-content-type helper and warning for decrypted attachments. (closes #3728)
* Fix parent_hdr usage in mutt_attach_reply(). (see #3728)
* Add option to run command to query attachment mime type. (closes #2933) (closes #3959)
Kevin McCarthy [Fri, 11 Aug 2017 16:04:48 +0000 (09:04 -0700)]
Fix parent_hdr usage in mutt_attach_reply(). (see #3728)
If the selected attachments are not messages and no (common) parent is
found, parent_hdr is set to the passed in hdr. In that case, parent
will still be NULL, but parent_hdr and parent_fp will be set.
Change the test to parent_hdr being NULL, not parent, to check for
this case.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:28 +0000 (18:18 -0700)]
Add edit-content-type helper and warning for decrypted attachments. (closes #3728)
Regenerating the actx index will overwrite any changes made to a
decrypted attachment. Change the mutt_edit_content_type() function to
return 1 when a structural change is made. Add a warning message when
that is the case and a decrypted message was edited, so the user is
not surprised.
Note: mutt_edit_content_type() appeared to regenerate multipart
subparts every time, leading to a memory leak. I believe this was an
oversite, and it should have regenerated only when there were no
subparts, so have "fixed" this.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:25 +0000 (18:18 -0700)]
Fix shared attachment functions. (see #3728)
With nested decryption, the correct FP is associated with the
ATTACHPTR entry. Also, the BODY entries are not continguous, so the
functions need to iterate over the actx index, not the BODY structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:20 +0000 (18:18 -0700)]
Add helpers to add and remove actx entries. (see #3728)
Use the helper in compose update_idx(), to consolidate the resize
logic and simplify the code.
Separate out the actx "free" routine from a routine to empty out the
idx. The index regeneration routines should flush and rebuild the
index without having to renerate the actx structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:18 +0000 (18:18 -0700)]
Create ATTACH_CONTEXT to hold attachment index. (see #3728)
Move the idx and idxlen into ATTACH_CONTEXT. In subsequence patches,
this structure will hold more useful items, such as the virtual index.
The swap out is straightforward, except for:
* update_idx() in compose.c, which post-increments the idxlen in the
call and again in the function.
* mutt_gen_attach_list() which doesn't need to returns the new values.
Damien Riegel [Tue, 22 Aug 2017 16:24:27 +0000 (12:24 -0400)]
move HelpStrings to help.c
HelpStrings was only defined when included in help.c (with the
`#ifdef HELP_C` guard), and it's only used there so move it to where it
belongs and make it static.
Damien Riegel [Tue, 22 Aug 2017 16:22:30 +0000 (12:22 -0400)]
use opcodes.h instead of keymap_defs.h
keymap_defs.h is a generated header and sometimes it falls out of the
sync with config.h, which leads to weird errors about opcodes being
undefined. Using a static header prevents that.
As both keymap_defs.h and keymap_alldefs.h are now gone, gen_defs is no
longer necessary and can be removed as well.
By passing a different formator to `OPS`, one can keep only parts of the
definition she/he is interested in. See the end of opcodes.h for example
usages.
By introducing this new header, it is no longer necessary to generate
keymap_alldefs.h, which was used only for consumption by gettext.
Damien Riegel [Tue, 22 Aug 2017 16:33:59 +0000 (12:33 -0400)]
define USE_NOTMUCH when creating the documentation
Header makedoc_defs.h is used in functions.h and init.h to define some
symbols when generating the documentation. Other mailbox backends are
defined (IMAP, POP), but notmuch was missing.
Fabrice Bellet [Fri, 4 Aug 2017 19:16:53 +0000 (21:16 +0200)]
color: call use_default_colors() in a single location
we call use_default_colors() when parsing colors in rc files only, and
unconditionally when defining the color of the tree element, because the
foreground color of the tree element may be combined dynamically with
the default background color of another element, not explicitely defined
in an rc file. This patch fixes a bug visible with some versions of the
ncurses library: use_default_colors() was used too late, and generated
color leakage effects. (#689)
Richard Russon [Mon, 7 Aug 2017 09:23:55 +0000 (10:23 +0100)]
merge: Standardise the handling of Lists
* Datastructures #1 - PoC of standardizing a couple of fields
* Add queue.h to EXTRA_DIST
* Convert userhdrs to STailQ
* Convert mix chain to STailQ
* HCache now depends on tailq structures instead of List
* Convert UserHeader to STailQ
* Convert MuttrcStack to STailQ
* Convert AutoViewList to STailQ
* Convert Muttrc to STailQ, start to gather common algos in list.h
* Convert AlternativeOrderList and (Attach|Inline)(Allow|Exclude) to STailQ
* Be consistent on variable names
* Convert HeaderOrderList and (Un)?Ignore to STailQ
* Convert MailtoAllow, MimeLookupList and SidebarWhitelist to STailQ
* Remove unused functions
* Convert List to STailQ in imap code
* Convert List to STailQ in ncrypt code
* Convert Hooks to TAILQ
* More idiomatic definition of HookHead
* Convert remaining List structures to STailQ in main.c
* Convert last List instances to STailQ, kill List definition
* Restore naming sanity: s/STailQ/List/g
* Fix list structure name in hcachever.sh
Pietro Cerutti [Fri, 21 Jul 2017 15:05:25 +0000 (15:05 +0000)]
Datastructures #1 - PoC of standardizing a couple of fields
This commits changes the type of two fields in envelope.h from struct List to
to struct STailQHead. This new structure represents a singly-linked tail queue
implemented using FreeBSD's queue.h (imported).
This is a proof of concept to see how we like using macros to implement basic
datastructures (singly and doubly linked lists and tail queues) and algorithms
(traversal, removal, insertion, ...).
I encourage everybody to have a look at the result and comment. Is this the
direction we would like to take?
This patch fixes the leak of index line attributes on the next line due
to the truncation of the output buffer based on terminal number of
columns, forgetting to include escapes sequence at the end of the input
buffer (#664).
Uses url_pct_encode to do the encoding. Note that url_pct_encode now
also encodes the ampersand, which shouldn't cause problems given that
it's only used for usernames and passwords otherwise.
Jenya Sovetkin [Thu, 3 Aug 2017 08:17:30 +0000 (10:17 +0200)]
nm_description_to_path: fix a mailbox type
In nm_description_to_path a mailbox type is supposed to be MUTT_NOTMUCH,
since the function queries the path of a *notmuch* mailbox using
a description string.
Pietro Cerutti [Fri, 4 Aug 2017 07:36:06 +0000 (07:36 +0000)]
Do not rely on backends setting error codes on success
From the API documentation of KyotoCabinet, TokyoCabinet and QDBM, I am
not convinced that the error code routines consistently return 0 whenever
the previous operation succeeded. Also, I am not convinced that they
return 1 whenever the previous operation failed.
It is important that we do not return 0 on failure, so let's try to get
the error code and fallback to -1 if we couldn't get anything more
specific.
Pietro Cerutti [Fri, 4 Aug 2017 06:40:41 +0000 (06:40 +0000)]
Review hcache implementation return codes
Especially, in this batch I have reviewed the return codes for fetch and
delete operations. KyotoCabinet, QDBM and TokyoCabinet were indeed
incorrectly implemented, as these backends generally return true on
success and false on failure.
I still have to investigate how to get a proper return code from QDBM.
Richard Russon [Thu, 3 Aug 2017 15:56:36 +0000 (16:56 +0100)]
merge: upstream fixes (mutt/default)
* Fix menu color calls to occur before positioning the cursor. (see #3956)
* Change imap_cmd_start() to return OK when the cmd_queue is finished. (closes #3956)
* When guessing an attachment type, don't allow text/plain if there is a null character. (see #2933)
* Add timeout parameter to mutt_socket_poll.
* Add $imap_poll_timeout to allow mailbox polling to time out.
* Convert raw_socket_poll() to use gettimeofday().
Kevin McCarthy [Sun, 23 Jul 2017 02:48:50 +0000 (19:48 -0700)]
Add $imap_poll_timeout to allow mailbox polling to time out.
Enable the polling flag for the NOOP in imap_check_mailbox(), the
STATUS command in imap_buffy_check(), and the LOGOUT command.
This is not intended to handle all blocking-IO related issues.
However, the periodic NOOP and STATUS are the most frequent places for
mutt to freeze up, especially after a laptop is sleep/woken.
Since these are quick operations with little data, this is a good place
to check if the connection is still working before hanging on a read.
Kevin McCarthy [Fri, 21 Jul 2017 00:30:05 +0000 (17:30 -0700)]
When guessing an attachment type, don't allow text/plain if there is a null character. (see #2933)
Type text/plain should not contain any null characters. Slightly
improve the type guesser by forcing an attachment with any null
characters to be application/octet-stream.
Note the type guesser could use much more improvement, but this is an
easy and obvious fix.
Kevin McCarthy [Wed, 19 Jul 2017 21:04:39 +0000 (14:04 -0700)]
Change imap_cmd_start() to return OK when the cmd_queue is finished. (closes #3956)
Some response handlers can end up recursively calling
imap_cmd_start(), processing all the command completions. If the
outer call was an imap_exec(), this would result in the loop never
being terminated (or just blocking reading a server that has already
finished all the commands).
Change the callers that are simply using it to read a response,
without having called cmd_start(), to check for IMAP_CMD_OK instead.
Currently this is just the open connection function.
Richard Russon [Wed, 26 Jul 2017 15:39:51 +0000 (16:39 +0100)]
tidy: drop unnecessary INITVAL usage
Variables with a static/global scope are automatically initialised to 0/NULL.
About 10 variables were initialised to non-zero values, but they were
reset with values from init.h before they were used.