RFC2045 declares tspecials to not include a period. So encoding it
inside 2231 parameter values, or adding double quotes to MIME
parameter values (such as in Content-Type and Content-Disposition)
because of the presence of a period, while not illegal, is
unnecessary.
Ticket 491 reported a case where some Android clients were not
decoding the "." in an attachment filename extension for some unknown
reason. While this is clearly a bug in the Android client, it's also
true that the period need not have been encoded in the first place.
However, "." couldn't simply be removed from MIMESpecials, because it
was also used for RFC2047 encoding. RFC2047 encoded-words are used in
non-MIME headers, and cannot be double quoted.
Create a third "specials" list, RFC2047Specials, adding back in the
".", to keep RFC2047 encoding the same as it was. Add a comment as to
why it exists, to prevent someone from making the unfortunate mistake
of thinking it can just be changed back to use MIMESpecials.
Thanks to Peter Seiderer for reporting the issue and suggesting a fix,
which this patch is based upon.
--disable-iconv seeds the cache value variable, $am_cv_func_iconv, to
"no" to skip the test and disable iconv.
However, the result of an existing and *working* AM_ICONV test is
stored in $am_func_iconv. The call to AC_DEFINE(HAVE_ICONV) depends
on that variable.
Mutt was improperly checking $am_cv_func_iconv below.
In the event of an existing but broken iconv, this would result in
HAVE_ICONV being undefined, but mutt_idna.o being added to
MUTT_LIB_OBJECTS. This would cause both the stub functions in
mutt_idna.h and the full functions in mutt_idna.c to be defined,
giving a compilation error.
Thanks to @juanitotc for the bug report and helping to test the fix.
Mutt is pretty consistent about NOT untagging automatically after an
operation. The only place where it does so is when deleting, but even
this is configurable via $delete_untag.
This works around Outlook sending application/pkcs7-mime ".p7m" parts
without a smime-type parameter.
Mutt previously hardcoded an assumption that these were SignedData to
work around an old Outlook book. However Outlook now appears to also
send EnvelopedData in this form.
The code was only looking to see if $envelope_from_address had a
value, not if $use_envelope_from was set.
Add extra safety checks to make sure the mailbox value isn't NULL.
If the account-hook invoked by mutt_conn_find() modifies
$envelope_from_address, envfrom could point no longer point to the
address.
Move the mutt_conn_find() before the code that determines the envelope
from address.
Under macOS, for a python script launched in a terminal, input() accepts only 1024 characters. In the authcode flow, the authorization code that is read by the call to input() around line 200 is longer than this and will be truncated, causing token retrieval to fail. Importing readline resolves this, allowing input() to accept a longer character string.
The standard iconv function uses char ** even for its input argument.
With a const char ** argument, ICONV_NONTRANS is incorrectly set to 1
if the compiler produces an error for such incompatible pointer types.
Although as far as I can see, the only thing that accomplishes is
disabling an assert, so it probably does not matter much.
This is another crash caused by the rfc2047 decoding bug fixed in the
second prior commit.
In this case, an empty header line followed by a header line starting
with ":", would result in t==end.
The mutt_substrdup() further below would go very badly at that point,
with t >= end+1. This could result in either a memcpy onto NULL or a
huge malloc call.
Thanks to Chenyuan Mi (@morningbread) for giving a working example
draft message of the rfc2047 decoding flaw. This allowed me, with
further testing, to discover this additional crash bug.
When composing an email, miscellaneous extra headers are stored in a
userhdrs list. Mutt first checks to ensure each header contains at
least a colon character, passes the entire userhdr field (name, colon,
and body) to the rfc2047 decoder, and safe_strdup()'s the result on
the userhdrs list. An empty result would from the decode would result
in a NULL headers being added to list.
The previous commit removed the possibility of the decoded header
field being empty, but it's prudent to add a check to the strchr
calls, in case there is another unexpected bug resulting in one.
Thanks to Chenyuan Mi (@morningbread) for discovering the two strchr
crashes, giving a working example draft message, and providing the
stack traces for the two NULL derefences.
For some reason, the rfc2047 base64 decoder ignored illegal
characters, instead of aborting. This seems innocuous, but in fact
leads to at least three crash-bugs elsewhere in Mutt.
These stem from Mutt, in some cases, passing an entire header
field (name, colon, and body) to the rfc2047 decoder. (It is
technically incorrect to do so, by the way, but is beyond scope for
these fixes in stable). Mutt then assumes the result can't be empty
because of a previous check that the header contains at least a colon.
This commit takes care of the source of the crashes, by aborting the
rfc2047 decode. The following two commits add protective fixes to the
specific crash points.
Thanks to Chenyuan Mi (@morningbread) for discovering the strchr
crashes, giving a working example draft message, and providing the
stack traces for the two NULL derefences.
Commit 012981e8 (in release 2.2.9) updated the GPGME autoconf files,
to fix a build issue with newer GPGME releases.
Unfortunatley that caused a build issue for hosts where the gpg-error
header files aren't in the include path. The newer autoconf file
expect GPG_ERROR_CFLAGS to be added to the list of flags for the
compiler.
Thanks to Will Yardley for reporting the issue and quickly testing the
proposed fix.
When uncollapsing, _mutt_traverse_thread() returns the virtual number
of the root message in the thread. <collapse-thread> directly sets
menu->current to this value to cause the cursor to be on the *first*
message of the thread (which isn't the same as the root message when
sort=reverse-threads). <collapse-all> finds the corresponding message
by searching for it after re-indexing.
However, when collapsing, _mutt_traverse_thread() had code to try and
find the *first* message in the thread and return that virtual number.
<collapse-thread> then did the same trick, because the old first
message is now the new root message for sort=reverse-threads.
However, that cleverness caused a bug for <collapse-all> - it can't
use that virtual number directly, and it can't "find" the message at
the index after reindexing.
To fix this, remove the cleverness from _mutt_traverse_thread() when
collapsing. Return the virtual number of the root. Add searching
behavior for <collapse-thread> to fix its behavior.
We don't want to copy the deleted flag over to the trash folder too.
I looked into various ways to keep the UID COPY, but they lead to
niggling issues with error handling along with handling if the server
sends flag updates back to the client.
So for that (hopefully rare) case, abort the fast trash and just use a
regular copy.
Split XOAUTH2 to use two steps.
This follows the microsoft.com documentation example for smtp. Since
office365 is the main site using XOAUTH2 now, it's better to match
their documentation.
It also matches msmtp's behavior, which probably means somewhere or
another needs it that way.
At the same time, improve response code checking. Mutt was using
smtp_get_resp() before, which returns 0 for both a ready and success
response code. Make sure it's a success response code when done
authenticating.
The character '/' from base64 alphabet breaks web redirectors if the
message-id from an email is used as part of the URL for redirectors and/
or automatic pointers to an email.
Use the URL safe alphabet from RFC4648 section 5 for message id
generation.
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
In the base64 safe URL dictionary the characters '+' and '/' are
replaced by '-' and '_'.
Add the characters to Index_64 to allow decoding if needed.
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
There are cases when using the 'authcode' grant where the authorization
request will succeed but the access token request will fail (for
example: if the user's web browser and terminal use different proxy
settings). The current implementation of the script does not inform
the user that the authorization token is being exchanged for an access
code, with the result that it can appear that a request has both
succeeded (according to the browser) and failed (according to the
terminal output) simultaneously. Add a message to inform the user that
a second request is being made so there is less potential for confusion.