Richard Russon [Thu, 18 Aug 2016 16:31:23 +0000 (17:31 +0100)]
merge: bug-neomutt
* add strndup.c strnlen.c
* More careful file writing for aliases and attachments
* Bye srandom() and random()
* Don't whine if getrandom() fails.
* Remove TLS version notification
* Use unlocked libc IO everywhere.
* debian: hurd build fix
* quieten two compiler warnings
* build tweak to allow testing
* separate key bindings for <return> and <enter>
* Add browser sort by description, message count and new message count
David Sterba [Thu, 24 May 2012 13:34:53 +0000 (15:34 +0200)]
feature: limit-current-thread
Add command to limit view on the thread from any of its message.
Predefined on command <ESC>L, though the lowercase 'l' would be better
(less keystrokes), but it's already occupied by a not-so-useful command
"show limit".
Tested on large folders, no performance problems observed.
Mike Frysinger [Tue, 31 May 2016 20:17:41 +0000 (21:17 +0100)]
separate key bindings for <return> and <enter>
Split up <enter> (ctrl+j) and <return> (ctrl+m) into different bindings so
people can map them differently. The default behavior is unchanged as we
map them both to the same function.
David Wilson [Tue, 22 Oct 2013 18:34:57 +0000 (11:34 -0700)]
Use unlocked libc IO everywhere.
Since mutt does not use threads, there is no reason it should use the
locked variants of the FILE* IO functions. This checks if the unlocked
functions are available, and if so enables them globally via mutt.h.
Cuts load time for a 56k message, 1.8GB /var/mail mailbox from 14
seconds to ~6 seconds, since we avoid acquiring and releasing a mutex
for every character of input read.
Adam Borowski [Sun, 7 Aug 2016 03:48:14 +0000 (05:48 +0200)]
Don't whine if getrandom() fails.
Debian for example supports kernels down to 3.2, and getrandom() appeared
only on 3.16 on x86 or later on other archs. Current stable has only 3.16
(ie, no getrandom() outside of x86), and ARM vendor kernels are for most
machines even older.
There is no security risk in falling back to /dev/urandom, as mutt quits
if that fails instead of using unsecure randomness.
This is a fix to commit "Bye srandom() and random()"
Sami Farin [Wed, 16 Oct 2013 18:34:57 +0000 (11:34 -0700)]
Bye srandom() and random()
Prefer getrandom on Linux, use /dev/urandom otherwise to
get entropy for MIME boundaries, message-id, Maildir filename,
temporary filename. Using MUTT_RANDTAG_LEN (currently 16) base32
characters for boundaries and message-id.
Sami Farin [Wed, 16 Oct 2013 18:34:57 +0000 (11:34 -0700)]
More careful file writing for aliases and attachments
Use fsync and check for errors when appending to alias file,
saving attachments, and bouncing a message. Still more checks are needed.
Also preserve errno if safe_fsync_close fails.
Kevin McCarthy [Mon, 8 Aug 2016 20:13:30 +0000 (13:13 -0700)]
Clear pager position upon returning to the index menu.
This fixes a bug where opening a message sometimes shows it scrolled
down.
The easiest way to trigger this is to open a long message in a mailbox
with no new messages, scroll down, hit <next-new-then-unread> and then
reopen the message. The pager will "remember" the position and scroll
down. If you simply exit the message and re-enter it, the position is
not saved.
More annoyingly, once in a very great while I will open a new message
and have the message scrolled down partway. I believe this is due to
OldHdr happening to point to the same address as the Header of the new
message.
This is somewhat easily triggered on a mailbox with one message, which
you open, scroll down in, hit <next-new-then-unread> to exit, and then
delete/sync. In another mutt instance, copy the same messsage back to
the mailbox, then open the message in the original mutt instance. At
least some of the time, the OldHdr pointer matches the new message,
and so it opens scrolled down.
This patch solves the problem by clearing the pager position once all
redirections through the index menu are done.
Kevin McCarthy [Fri, 5 Aug 2016 21:33:39 +0000 (14:33 -0700)]
Remove nonsensical size check in mutt_choose_charset()
The charsets parameter is being tokenized by the : delimeter.
The checks against ENCWORD_LEN_MAX and ENCWORD_LEN_MIN make no sense,
and appear to be the result of a large merge a very long time ago
(changeset cb27682966d5).
I can only guess where this check was supposed to be, but it certainly
doesn't belong here.
Kevin McCarthy [Tue, 2 Aug 2016 01:25:28 +0000 (18:25 -0700)]
Use a different flag in mx_open_mailbox_append() when mailbox doesn't exist.
The previous commit re-used MUTT_NEWFOLDER, but the meaning of that
flag is slightly different: it causes mbox to use fopen with mode "w",
and is used only for the case of a brand-new mktemp-generated mbox.
Setting it for other non-existing mbox files leads to a race condition
between the stat and the fopen/lock, and so could end up truncating an
existing mailbox created in-between!
Create a different flag, MUTT_APPENDNEW to notify the open_append()
functions that the mailbox doesn't exist. Change maildir and mh to
check for that flag to create their directory structures.
Kevin McCarthy [Sat, 30 Jul 2016 18:11:07 +0000 (11:11 -0700)]
Add unread and total message count format strings to $folder_format.
%n will show the unread message count in the mailbox. %m will show
total message count. Except for %n with IMAP, these both require
$mail_check_stats to be set, which puts these counts inside BUFFY.
Since the imap_mboxcache is never fresher than the value in BUFFY,
remove the special imap_mailbox_state() call. Instead, just update
from the current Context for all mailboxes.
Remove the logic that overrode the %N format string to show unread
count for IMAP mailboxes. If they want to see unread count, they will
have to change the $folder_format.
Although it doesn't look possible to reuse browser_state.entry slots,
change the OP_DELETE_MAILBOX to memset(0) the deleted slot. Then, we
can change to logic in add_folder() so it doesn't need to zero-out
unset values.
Anton Lindqvist [Wed, 20 Jul 2016 01:56:13 +0000 (18:56 -0700)]
Fix arithmetic exception due to menu->pagelen being negative.
Resizing the terminal window down to two lines when in an empty
mailbox causes mutt to crash due to division by zero since menu->max
equals 0 and menu->pagelen < 0 in status.c:205.
Fixing the problem at this specific line felt wrong since I did notice
menu->pagelen being negative. The pagelen is inherited from the rows
calculation in mutt_reflow_windows. Since the number of lines can
potentially be smaller than the accumulated number of rows acquired by
the status, help and message window, make sure the calculation does
not turn negative.
Kevin McCarthy [Mon, 18 Jul 2016 02:31:16 +0000 (19:31 -0700)]
Add imap-fast-trash patch.
This is based on the patch by Paul Miller.
Modifications are:
* Create a new flag, MUTT_TRASH for imap_make_msg_set(), rather than
use MUTT_EXPIRED.
* Change imap_make_msg_set(MUTT_TRASH) to only look at
hdrs[n]->deleted && !hdrs[n]->purge, behaving like MUTT_TAG, rather
than looking at the HEADER_DATA.
* Reimplement imap_fast_trash() based on imap_copy_message().
It looks the old version was too, but it lacked handling of TRYCREATE
and also queued the UID COPY but didn't exec it. (Presumably this
happened in the subsequent sync).
* Move the Context magic and mx_is_imap() checks outside of
imap_fast_trash()
Kevin McCarthy [Mon, 18 Jul 2016 02:31:09 +0000 (19:31 -0700)]
Add the trash folder patch.
This is based on the trash folder patch by Cedric Duval.
Modifications to the original patch are:
* Use a flag called M_PURGE instead of M_APPENDED. The same flag is
then used in the following "purge" patch instead of adding a
different flag.
* Removed the counter in context. The existing context->deleted
is all that's needed.
* Removed the "auto unset M_PURGE" when M_DELETED is unset inside
_mutt_set_flag(), although this is convenient, it easily leads to
header->purge not being reset in a few situations.
* Reset purge flag along with the deleted flag if $delete is answered
no.
* Set M_PURGE on an edited message. (edit_one_message())
* Preserve purge flag in mutt_reopen_mailbox()
* Turn off OPTCONFIRMAPPEND when saving to the trash, rather than
hardcoding it off in mutt_save_confirm(). That way, normal save to the
folder will respect the option.
Kevin McCarthy [Tue, 12 Jul 2016 01:36:21 +0000 (18:36 -0700)]
Initialize mutt windows even in batch mode. (closes #3853)
mutt_select_fcc() calls mutt_addr_hook() -> mutt_make_string() which
refers to MuttIndexWindow->cols when calling mutt_FormatString(). In
batch mode, MuttIndexWindow hasn't been initialized, leading to a
segfault.
This might be the only overlap, but it seems wiser to just initialize
the mutt windows in case there are other references (now or in the
future) when processing format strings in batch mode.
Kevin McCarthy [Sat, 9 Jul 2016 01:52:56 +0000 (18:52 -0700)]
Change sidebar highlighted mailbox behavior.
Delay selecting the highlighted mailbox until prepare_mailbox(), to
avoid a hidden mailbox being selected during the Buffy list population
(in mutt_sb_notify_mailbox()).
Change update_entries_visibility() to not automatically make the
highlighted mailbox visible.
Change prepare_sidebar() to (re)set the highlighted mailbox when the
current highlighted mailbox is hidden.
Kevin McCarthy [Sat, 9 Jul 2016 01:47:57 +0000 (18:47 -0700)]
Don't overwrite imap_status->uidnext with a lower value. (closes #3771)
imap_read_headers() updates the idata and imap_status uidnext after
reading through all the new headers.
The idata is updated properly (only if its uidnext is below maxuid+1),
but the imap_status was always being set to maxuid.
This causes a problem with new mail checking if the most recent
messages are deleted. Then the uidnext will be greater than maxuid+1
in the mailbox, and if there are any other unread messages it will
*always* report new mail even if $mail_check_recent is set.
Kevin McCarthy [Sat, 2 Jul 2016 19:24:25 +0000 (12:24 -0700)]
Fix sidebar "unsorted" order to match Buffy list order.
Since the previous commit decoupled the sidebar from the Buffy list,
we can now restore the order to match the buffy list when
sidebar_sort_method is set (back) to "unsorted".
Kevin McCarthy [Sat, 2 Jul 2016 19:22:51 +0000 (12:22 -0700)]
Decouple the sidebar from the Buffy list.
Change the sidebar to use an array of SBENTRY* instead. Move the
"is_hidden" into SBENTRY. Remove the added "prev" pointer from BUFFY.
This way, sorting the sidebar doesn't affect the BUFFY list order, and
we don't need elements inside BUFFY just for the sidebar presentation.
Fix sidebar-next for the case where the mailboxes are unsorted and
$sidebar_new_mail_only is set. Change sorting not to clump hidden
mailboxes at the bottom, instead simply skip over hidden mailboxes in
sidebar-next/prev.
Kevin McCarthy [Fri, 1 Jul 2016 20:33:20 +0000 (13:33 -0700)]
Check $pgp_autoinline and $pgp_replyinline if oppenc is set. (closes #3846)
The first oppenc call takes place after the initial checks of
$pgp_autoline and $pgp_replyinline, and doesn't go through the pgp
menu.
Therefore, check for $pgp_autoline and $pgp_replyinline if oppenc is
set too, to avoid oppenc enabling encryption without INLINE being set
in those cases.
a6a4d6ed0f19 previously cleaned things up so that it is safe
to set INLINE even if encryption isn't enabled.
USE_SIDEBAR needed to be set in doc/makedoc-defs.h so that the sidebar
option documentation is generated whether mutt is configured with the
sidebar or not.
Kevin McCarthy [Thu, 30 Jun 2016 01:58:53 +0000 (18:58 -0700)]
Fix cppflags and muttlibs duplication with --with-gss.
When krb5-config was found, MUTT_AM_PATH_GSSAPI included CFLAGS in
GSSAPI_CFLAGS and MUTTLIBS in GSSAPI_LIBS. However, configure.ac
afterwards sets:
CPPFLAGS="$CPPFLAGS $GSSAPI_CFLAGS"
MUTTLIBS="$MUTTLIBS $GSSAPI_LIBS"
This caused the flags and libs to be duplicated.
Kevin McCarthy [Thu, 30 Jun 2016 01:58:48 +0000 (18:58 -0700)]
Include ncurses tinfo library if found.
Thanks to Fabian Groffen for reporting this issue and providing a
couple possible patches. From Fabian's report:
For some time now, ncurses can be built in a mode where the low level
terminfo functionality lives in a separate lib called libtinfo.
Because some people do, this means Mutt needs to include this
library in that case to avoid linking errors [...]
Remove $sidebar_refresh_time from Sample Sidebar Config
The $sidebar_refresh_time option was removed with the changeset 1f840760e6e0. Remove it from the sample sidebar configuration as well,
so that anyone using that file in its entirety won't have to deal with "unknown
variable" errors.
Kevin McCarthy [Thu, 23 Jun 2016 19:38:07 +0000 (12:38 -0700)]
Change sidebar to consistently use realpath for context and buffy comparison.
The original sidebar patch contained a half-implemented attempt to use
realpath() mailbox paths for comparison. (Presumably so the open mailbox
remains highlighted despite symlink issues).
Add realpath to the Context, and set it when opening a mailbox.
Remove sidebar ifdef for the buffy member, and always set it there too.
Change the sidebar to use the realpath for comparison everywhere.
mutt_buffy_check() is using stat device and inode for comparison.
Perhaps this can be changed to use realpath instead, but that's beyond
the scope of this patch.