sasl_client_step() returns SASL_OK after the fourth step: server auth
confirmation. However, the protocol requires the client send one more
blank line to the server, to which the server then replies with "+OK".
See https://tools.ietf.org/html/rfc5034#section-6.
The code currently only sends a final response if sasl_client_step
returns data to send. Change it to always send a final client message
after the SASL_OK.
Kevin McCarthy [Thu, 6 Oct 2016 19:35:38 +0000 (12:35 -0700)]
Mark IMAP fast-trash'ed messages as read before copying. (see #3860)
Regular copying/saving messages in mutt via a UID COPY first calls
imap_sync_message(). However that function is designed to sync all
flags (including deleted), and so isn't useful for the fast-trash
code.
As an easier solution, instead add a UID STORE to set \\Seen for the
same msgset as the trashed messages.
Kevin McCarthy [Tue, 4 Oct 2016 18:13:24 +0000 (11:13 -0700)]
Preserve forwarded attachment names in d_filename.
When forwarding an attachment with an non-ascii name, mutt_copy_body()
mangles the filename when calling mutt_adv_mktemp. Preserve
the original attachment filename in d_filename.
Remove the double copy of b->filename, which is a memory leak.
Kevin McCarthy [Sat, 1 Oct 2016 23:21:59 +0000 (16:21 -0700)]
Ensure signatures exist when verifying multipart/signed emails. (closes #3881).
TAKAHASHI Tamotsu reported that when gpg2 isn't in PATH, the
gpgme_op_verify() won't return an error, but instead will return a
result with no signatures.
verify_one() was only returning an error if a signature actually
failed, so in this case the function was defaulting to returning
success.
Other callers of gpgme_op_verify() check to make sure the
result->signatures exist before processing signatures. Add a check
for verify_one() too.
Kevin McCarthy [Sat, 1 Oct 2016 20:58:35 +0000 (13:58 -0700)]
RFC2047-decode mailto url headers after RFC2822 parsing. (closes #3879)
Commit 55819a7e6169 performed the RFC2047 decode before the parsing.
This works okay for headers such as subject, but for others such as
address fields could lead to parsing errors.
Change to perform a decode on envelope headers after all the calls to
mutt_parse_rfc822_line(), using the same list of fields as
mutt_read_rfc822_header().
Change the do_2047 parameter of mutt_read_rfc822_line() to true, so
that user headers are decoded if needed.
Kevin McCarthy [Sun, 25 Sep 2016 20:11:03 +0000 (13:11 -0700)]
Reset invalid parsed received dates to 0. (closes #3878)
The actual problem in the ticket would be solved by d3f31cf9239e (see
#3798). However there is still the bug that Mutt considers a
(hdr->received != 0) to be set and usable, despite not checking the
return value of mutt_parse_date().
Change mutt_read_rfc822_header() to unset an invalid received value
back to 0. We don't do this inside mutt_read_rfc822_line() because
that would cause the next received line to be parsed.
Kevin McCarthy [Fri, 23 Sep 2016 23:07:36 +0000 (16:07 -0700)]
Clear pager position when toggling headers.
It doesn't make sense to try to preserve the pager position when
toggling headers: the purpose of toggling headers is to see the
headers in full or weeded state. So, reset the position back to the
top.
Kevin McCarthy [Thu, 22 Sep 2016 21:07:18 +0000 (14:07 -0700)]
Don't abort the menu editor on sigwinch. (closes #3875)
getch() will return ERR on sigwinch when timeout() is called with a
positive value. mutt_getch() will therefore return ch==-2 for both a
timeout and a sigwinch in this case.
The imap code in km_dokey() exits out of the ImapKeepalive loop for a
SigWinch, and was skipping past the check for MENU_EDITOR and
tmp.ch==-2. Move this check below the gotkey: label so the
ImapKeepalive loop behaves the same as the Timeout code.
Thanks to nicop for reporting the problem and for the initial patch!
Antonio Radici [Thu, 22 Sep 2016 01:10:33 +0000 (18:10 -0700)]
Mark some gpgme pgp menu keybinding translations as fuzzy. (closes #3874)
Some translations for crypt-gpgme.c are marked as fuzzy but the keybindings
attached to these translations are not, this creates confusions for the users
who see the english message but have the keybindings for a message in their own
language available.
As long as the translations are fuzzy, the keybindings should stay fuzzy.
Kevin McCarthy [Wed, 21 Sep 2016 20:51:01 +0000 (22:51 +0200)]
Check for NULL mx_ops in mx.c
Eike Rathke reported this happening when in an IMAP index view the
underlying connection was terminated, ctx->mx_ops was NULL and thus
accessing ctx->mx_ops->check segfaulted.
Thanks also to Eike Rathke for the initial patch, for which I expanded
the checks to other functions.
Antonio Radici [Tue, 20 Sep 2016 22:51:13 +0000 (15:51 -0700)]
Use body color for gpgme output. (closes #3872)
When switching from pgp_* commands to crypt_use_gpgme=yes, Peter
Colberg noticed that the output was colored 'brightyellow'.
The issue is that crypt-gpgme.c uses state_attach_puts in various
places where it should use state_puts to maintain compatibility with
the previous behavior in pgp.c.
Kevin McCarthy [Mon, 5 Sep 2016 19:35:19 +0000 (12:35 -0700)]
Stub out getdnsdomainname() unless HAVE_GETADDRINFO.
It seems unlikely there are systems without it (given that this
mistake has been in since 1.6.0), but for correctness we should stub
out the function for those without it.
Kevin McCarthy [Sat, 3 Sep 2016 23:19:38 +0000 (16:19 -0700)]
Preserve message-id and mft headers for recalled messages. (closes #3081)
Git patch creates a patch series mailbox, including the Message-ID.
Using this as draft files was removing the Message-ID, and thus
breaking the threaded structure.
The second part of the ticket has already been addressed by 95a2230ef889 (for ticket 3653).
Kevin McCarthy [Sat, 3 Sep 2016 02:32:39 +0000 (19:32 -0700)]
Disable ~X when message scoring. (closes #3861)
mutt_score_message() purposely passes a NULL context to
mutt_pattern_exec(). The idea was to block slow patterns, and the
scoring documentation notes this by saying:
"For efficiency reasons, patterns which scan information not
available in the index, such as ~b, ~B or ~h, may not be used"
~X needs the context to parse the messages (during message scoring at
least), and thus isn't suitable for message scoring either.
Block ~X from being used when the context is NULL. Add ~X to the list
of patterns noted as unusable in the message scoring documentation.
David Champion [Tue, 30 Aug 2016 23:11:45 +0000 (16:11 -0700)]
Update a confusing and obsolete comment.
This 2004 comment in sort.h predicted what has recently come to pass, so
I'm reframing it just to document for future devs what's going on with
this oddball flag.
Kevin McCarthy [Tue, 23 Aug 2016 03:04:52 +0000 (20:04 -0700)]
Remove the $locale configuration variable.
$locale was only used to set the LC_TIME locale. Unfortunately, Mutt
previously defaulted to using "C". This overrode the user's locale
setting and forced them to re-specify their locale inside their
.muttrc.
Remove $locale and instead use the locale specified by the
environment. Mutt still allows "C locale" dates by using a leading
"!" in $date_format, ${}, etc.
Another use of $locale was to customize attribution dates using hooks.
The next commit will introduce $attribution_locale, which can be used
for this instead.
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.