David Champion [Tue, 24 Jan 2017 03:01:50 +0000 (19:01 -0800)]
Add subjectrx command to replace matching subjects with something else.
This lets you define regular expressions-replacement pairs for subject
display. When a Subject: matches the regular expression, the replacement
value will be displayed instead in the message index. Backreferences
are supported.
This is especially nice for simplifying subjects that are overly wordy,
such as mailing list posts (with [Listname] tags, etc), mail from
ticketing systems or bug trackers, etc. It lets you reduce clutter in
your mutt display without altering the messages themselves.
David Champion [Tue, 24 Jan 2017 03:01:36 +0000 (19:01 -0800)]
Abstract the SPAM_LIST as a generic REPLACE_LIST
REPLACE_LIST can be used more generally as a list of pattern
match-replace settings. SPAM_LIST was a special case of this, so
spam handling has been been changed to use REPLACE_LIST instead, and
SPAM_LIST was removed.
A generic function for performing a REPLACE_LIST replacement has
been added in mutt_apply_replace().
Commited by Kevin McCarthy with some buffer overflow fixes in
mutt_apply_replace().
Kevin McCarthy [Tue, 24 Jan 2017 02:46:16 +0000 (18:46 -0800)]
Improve Reply-to vs From comparison when replying. (closes #3909)
Prior to this patch, if the Reply-to mailbox matched the From mailbox,
mutt would always use the From address. This was probably done to
preserve the display name, as the Reply-to address is often missing one.
Unfortunately, there are circumstances where the Reply-to display-name
has significance, such as in ticket 3909.
Change mutt so that it only uses the From address if the Reply-To has
no display-name.
Kevin McCarthy [Wed, 18 Jan 2017 00:09:16 +0000 (16:09 -0800)]
Fix several alias hashtable issues.
Convert to use the strdup keys hash. Addresses can be converted back
and forth from intl to local forms. This frees and recreates a new
addr->mailbox string, resulting in the hash table key being a dangling
pointer.
Change alias hash table insert/remove to ensure the address is in intl
form. The alias menu (previously) converted address entries to local
form when performing a completion. Even with the pointer issue fixed,
the entries may not be removed from the hash if the intl and local
forms are different.
Lastly, there is no reason for the alias menu to manually convert to
local form before writing the address to the output buffer.
rfc822_write_address() has a display parameter that will call
mutt_addr_for_display() instead when set. Change to set the display
parameter and remove the conversion calls.
This last change obviates the first two changes, but they are a good idea
in any case.
Kevin McCarthy [Wed, 18 Jan 2017 00:09:11 +0000 (16:09 -0800)]
Add casecmp and strdup_key flags to hash_create()
Aliases and (in the future), X-Label hashes will require a hash that
strdups the key. Convert the casecmp parameter of hash_create() to a
flags parameter, and add a flag to strdup the keys.
David Champion [Sun, 15 Jan 2017 03:18:45 +0000 (19:18 -0800)]
Allow initial blank lines in local mailboxes.
Some mailbox-creation tools erroneously append a blank line to a file
before appending a UNIXv7-format mail message, resulting in mailboxes
that are intended to be valid "mbox" folders but are not. Notably old
versions of Mailman do this, making archive files that cannot be read by
mutt.
This patch causes mutt to skip leading NLs and CRs when detecting magic.
Kevin McCarthy [Fri, 6 Jan 2017 22:17:10 +0000 (14:17 -0800)]
Convert HASH to be indexable by unsigned int. (see #3905)
Convert the HASH to be usable for either string or unsigned int keys,
so that a uid hash can be added for imap.
To keep hash-usage code disruption to a minimum, this introduces new
create/insert/find/delete functions for the int hash, but keeps the
old function names for string keys.
This implementation makes the key a union. It may have been a better
idea to introduce a whole new structure, but this way allows minimum
changes to and maximum reuse of the existing hash code.
Kevin McCarthy [Thu, 5 Jan 2017 03:45:59 +0000 (19:45 -0800)]
Fix imap server-side search to call uid2msgno() only once. (see #3905)
After performing a UID SEARCH, the results are parsed in
cmd_parse_search(). This was accidentally calling uid2msgno() twice.
Since that function does a linear search, this has a noticable impact
on large search results.
Kevin McCarthy [Tue, 3 Jan 2017 02:08:17 +0000 (18:08 -0800)]
Add a pattern_cache_t to speed up a few repeated matches.
Vincent Lefèvre reported experiencing an index display performance
issue. This occurred with messages containing many recipients. He
had many index color lines containing ~l. The ~l ended up being run
over and over on these messages, resulting in a noticable slowdown
displaying the index.
This patch adds caching for just a few of the pattern operations (~l,
~u, ~p, ~P) that are potentially expensive and also don't have
arguments. The caching is only enabled for operations repeatedly
matching against the same message: color, hooks, scoring.
The caching is fairly targeted, but isn't that invasive or
complicated.
Kevin McCarthy [Sun, 1 Jan 2017 03:57:07 +0000 (19:57 -0800)]
Canonicalize line endings for GPGME S/MIME encryption. (closes #3904)
This matches the behavior for S/MIME classic mode: OpenSSL converts
the line endings to cr/lf before encrypting. Although Mutt always
canonicalizes the line endings before verifying the signature, some
clients do not do this for encrypted messages.
Damien Riegel [Sun, 5 Feb 2017 01:51:17 +0000 (20:51 -0500)]
refactor: create a generic base64 encode/decode
- make sendlib use generic base64 encode function
Sendlib had its own implementation for base64 encoding, so change it to
make use of the generic one defined in base64.c. While we're at it, move
the B64Chars where it belongs, and remove some global variables by
creating a b64_context structure to hold all necessary information.
- make rfc2047 use generic base64 encode function
This was another source of a custom base64 encode function. Let's keep
the same logic as before: encode 3 bytes (or less) at a time. Also,
switch from a `for` to a `while` loop as `dlen` can simply be used as a
stop condition.
Damien R [Thu, 9 Feb 2017 21:16:07 +0000 (16:16 -0500)]
debug: remove dprint in favor of mutt_debug (#375)
The dprint macro is error-prone. Any FILE* can be passed to dprint, but
the macro checks that `debugfile` is not NULL (ie. it's open), not the
file pointer it received as parameter. This had also the consequence
that `debugfile` is passed to every call to `dprint`, making lines
unnecessarily long.
This commit replaces calls to `dprint` by direct calls to `mutt_debug`.
It's now hardcoded in this function that it will write in `debugfile`.
Also, remove the MUTT_LIB_WHERE magic.
The substistution has been done with the following command:
perl -0777 -pi -e 's/dprint[ ]*\((.+?),[ \t\r\n]*\(debugfile,[ ]*(.*?)\)\);/mutt_debug (\1, \2);/igs' *.c imap/*.c
And the code was then slightly ajusted to fix identation and line
length.
Guillaume Brogi [Mon, 6 Feb 2017 19:27:10 +0000 (20:27 +0100)]
Use mutt_buffer_init instead of memset
The mutt_buffer_init function does a memset to 0 of its argument, so use
it instead of doing a manual memset.
I noticed (thanks to @zmo) that a number of buffer used in hooks where
initialised using memset instead of this dedicated function. This
remedies to that.
Pietro Cerutti [Wed, 1 Feb 2017 15:52:40 +0000 (15:52 +0000)]
If possible, only redraw after gpgme has invoked pinentry (#352)
If possible, only redraw after gpgme has invoked pinentry
This requires gpgme >= 1.8.1, which exposes a new "redraw" status flag.
On older versions, fallback to always redraw if pinentry was potentially called.
Thanks to Werner Koch for the hints!
guiniol [Wed, 1 Feb 2017 13:26:35 +0000 (14:26 +0100)]
Remove two use-after free in global hooks (#353)
Fixes #347
In both mutt_timeout_hook and mutt_startup_shutdown_hook, we iterate on
the list of hooks and try to execute the right ones, always using the
same buffer. The buffer must be free'd after all the hooks have been
checked and not after the first hook which fails. This also removes a
memory leak, because the buffer was never freed if no hook failed.
Richard Russon [Mon, 23 Jan 2017 16:15:43 +0000 (16:15 +0000)]
merge: add a recursive mkdir function
* lib: add mutt_mkdir
* create tmpdir
* bcache: use mutt_mkdir()
* nntp: use mutt_mkdir
* hcache: use mutt_mkdir
* Optimise the case of an existing cache file
Guyzmo [Tue, 10 Jan 2017 12:59:40 +0000 (13:59 +0100)]
Support of relative paths sourcing and cyclic source detection
Added HEAP/FILO structure and global singleton to contain the the list
of config files that have been sourced, and detect cyclic sourcing.
Implemented with a simple heap API:
Added a new method `to_absolute_path()` to convert a path into an absolute
path, relatively to another config file's path. Using POSIX methods to
do so, adding libgen's header in `mutt.h`.
Ian Zimmerman [Fri, 16 Dec 2016 18:42:36 +0000 (10:42 -0800)]
Extend the ~m pattern to allow relative ranges
The ~m pattern now accepts absolute ranges, relative ranges and has some
mnemonics (shortcuts).
There are shortcuts for some emails:
^ First email
. Current email
$ Last email
These shortcuts can be used anywhere a number is used in the examples
below.
Relative ranges have a comma ',' in them:
-3,. Previous 3 emails plus the current one
.,$ Current email and all the later ones
-2,2 Previous 2, current and next 2 emails
0,1 Current and next email
Richard Russon [Wed, 18 Jan 2017 16:57:02 +0000 (16:57 +0000)]
merge: notmuch search windows
* Searching with a window over notmuch vfolders
* Fix of the sidebar item highlight when matched by current search
* Makes the sidebar show the real msg count on the current mailbox
* Add doxygen documentation comments
* Improving the API naming and typing
Bernard Pratz [Sat, 7 Jan 2017 18:08:53 +0000 (19:08 +0100)]
Makes the sidebar show the real msg count on the current mailbox
run a notmuch count when loading values for the currently highlighted
mailbox when drawing the sidebar up, to show the request's total number
instead of just the window's number.
Bernard Pratz [Sat, 7 Jan 2017 17:52:55 +0000 (18:52 +0100)]
Fix of the sidebar item highlight when matched by current search
Because searches done manually (or shifted with a window) have an
absolute path to the current Maildir within the URI, whereas the one
declared with the virtual-mailboxes command usually have implicit
Maildir path specification, this patch parses the given URL of a mailbox
and re-builds it to contain the full path.
For that purpose has been added:
- nm_normalize_uri() function
Has been modified:
- get_query_string (in mutt_notmuch): earned an argument to disable
adding of a window in the context of the nm_normalize_uri function.
- mutt_parse_virtual_mailboxes: the path value is sent through the
nm_normalize_uri() function to be normalized.
Bernard Pratz [Sun, 15 Jan 2017 19:53:09 +0000 (19:53 +0000)]
Searching with a window over notmuch vfolders
following up on #278
Instead of adding a new command for searches that will result in
windowed searches, this commit patches a lower function of the search
mechanism, the `get_query_string()` function.
There, any search is buffered in the `nm_query_window_current_search`
global variable. And a newly introduced non-exposed function
`window_query_from_query` is taking a `data->db_query` and adds a
`date:` field implementing the window.
That function won't add a `date:` field if there's no duration set or if
there's already a date field in the query (to avoid risks of an empty
intersection).
To disable the feature, just set `nm_query_window_duration` to `0`.
The improvements over #278 implementation is that now it's working with
any search done with notmuch, whether it's a `virtual-mailbox` or using
the `vfolder-from-query` command.
Richard Russon [Sun, 15 Jan 2017 01:22:48 +0000 (01:22 +0000)]
reformat the source to mutt standards
reindent - 2 spaces
braces {} on new line
indent case statements
bracket logic - () around complex bools
rename static functions - drop "nm_" prefix
move functions - static first
move mx_ops functions to end
fix typos
reorder includes
add some doxygen comments