Kevin McCarthy [Fri, 7 Jun 2019 20:43:36 +0000 (13:43 -0700)]
Improve imap_append_message() error message handling.
If the rc is IMAP_CMD_BAD, then either idata->buf is stale or an error
message has already been printed (in cmd_handle_untagged()).
Use imap_next_word() to skip over the next two words instead of
directly skipping over SEQLEN, in case the buffer is in a different
format. We don't want to jump over the end of string.
Skip the mutt_error() if there is nothing to print.
Kevin McCarthy [Thu, 6 Jun 2019 23:03:42 +0000 (16:03 -0700)]
Enable the idata->check_status using bit operations.
Commit e3f66d7e fixed dropped new mail notications, removing the
unsetting of idata->reopen IMAP_NEWMAIL_PENDING in imap_cmd_finish()
when an EXPUNGE was processed.
However, imap_cmd_finish() can be called twice by
imap_check_mailbox(). First as part of the imap_exec(), and manually
again just below.
Now that the IMAP_NEWMAIL_PENDING still exists, a second call could
overwrite idata->check_status if both reopen flags were set.
This unfortunately affects update_index(), which behaves differently
for MUTT_REOPENED.
I need to change the return value of mx_check_mailbox() in master to
preserve all the bits, so the index can both notify of new mail and
update_index() properly.
For stable, the best fix is to use bit operators to enable the
check_status flags in imap_cmd_finish() (and cmd_parse_fetch for
flags), and keep the imap_check_mailbox() priority of setting its
return value (it prioritizes IMAP_EXCHANGE_PENDING).
Kevin McCarthy [Thu, 6 Jun 2019 20:38:03 +0000 (13:38 -0700)]
Improve robustness of imap_append_message().
First, check the imap_cmd_step() return value instead of looking at
idata->buf for "OK". If the connection bombed and imap_cmd_step()
returned IMAP_CMD_BAD, the value of idata->buf is stale.
If the server returned "+ OK" for the command continuation request
response, the call to imap_code(idata->buf) would even end up
returning true, despite that the append failed! (See #110, although
at the time of commit I can only hypothesize this is what is
happening.)
Second, check the status of the writes. flush_buffer() was not
passing the rc from mutt_socket_write_n(), which was further making
the above disaster scenerio possible.
Kevin McCarthy [Wed, 5 Jun 2019 21:04:55 +0000 (14:04 -0700)]
Fix dropped new mail notifications when an EXPUNGE_PENDING is set.
Prior to the fetch_headers rework and introduction of
idata->max_msn (starting around e0376c75), cmd_handle_untagged() was
looking directly at ctx->msgcount, which isn't fixed up until
imap_expunge_mailbox(). At that time, more care had to be taken
inbetween handling the EXPUNGE message and the actual expunge of the
mailbox because of the discrepency between server state and mailbox
context state.
idata->max_msn is now decremented during the processing of EXPUNGE and
VANISHED notices from the server, so reflect "current" state. So,
when we receive an EXISTS notice, we no longer need the checks for
expunge state and can always set the NEWMAIL_PENDING flag.
Additionally, fix imap_cmd_finish() to retain the IMAP_NEWMAIL_PENDING
flag after handling an expunge. The expunge does not grab new
messages so dropping the flag would cause mutt to forget the new mail
status until another EXISTS command.
Since this is a stable branch fix, I'm leaving the either/or
processing of expunge versus new mail in imap_cmd_finish(). However,
I don't see why this has to be done in two calls. I may rework that
in master to process an expunge and then the new mail one after the
other.
Kevin McCarthy [Fri, 31 May 2019 16:37:38 +0000 (09:37 -0700)]
Remove FORCE prerequisite on version.h.
This is causing package build issues on OpenBSD because of a
difference in make behavior.
In GNU make, it always invoke the 'version.h' target, but then checks
to see if version.h changed before retriggering targets with that
prerequisite. On OpenBSD, invoking the version.h target always
retriggers targets with that prerequisite.
This means that updating the version information now requires a 'make
clean' or manual removal of version.h.
Kevin McCarthy [Tue, 28 May 2019 16:38:38 +0000 (09:38 -0700)]
Remove EXTRACT_MACROS check from EXTRACT_NUMBER in regex.
Commit 367b1135 converted EXTRACT_NUMBER to always call a function, to
enable the use of parameter types and local variables. In doing this
it removed the separate DEBUG implementation.
The EXTRACT_MACROS check was accidentally left in, but no longer makes
sense outside of the DEBUG.
Kevin McCarthy [Tue, 28 May 2019 02:45:58 +0000 (19:45 -0700)]
Rename --with-regex to --with-bundled-regex.
This makes the configuration option purpose clearer. Previously,
some distros enabled the option thinking it turned on a "regex" option
that should be enabled.
Kevin McCarthy [Sun, 26 May 2019 21:34:42 +0000 (14:34 -0700)]
Turn on $ssl_force_tls by default.
Ticket #135 suggests that these days, it's better to force encryption
over all connections. RFC8314 is recommending MUA's move in that
direction (actually even directing towards implicit TLS over
STARTTLS).
I'm enabling this at the beginning of the 1.13 development cycle to
give others time to chime in with any objections. Personally, I've
had this option set myself for years. The only place it could become
an issue is for a localhost IMAP server with no cert. In that case,
it's easy enough to have an account hook unset if needed, and I think
a better idea that the user be forced to turn it off.
Sebastian Stark [Sun, 26 May 2019 16:52:47 +0000 (18:52 +0200)]
make OP_HALF_{UP,DOWN} behave symmetric.
- the calculation of number of lines to scroll up/down should not
depend on whether the number of rows in the pager/index/terminal is
odd or even.
- this patch will make the behaviour symmetric such that in both cases
(even/odd number of rows) scrolling up and down by half a page (or the
other way round) will get you back to the exact same line as before.
Kevin McCarthy [Sat, 25 May 2019 21:26:08 +0000 (14:26 -0700)]
Disable state messages for attachments when forwarding.
First, option(OPTVIEWATTACH) is only set for (s->flags & DISPLAY), so that
check can be ignored.
With that removed, all this is doing is printing
[-- This is an attachment ...]
with no context in the middle of non-display rendering for the case
$honor_disposition is set with a handler.
This makes no sense and I believe is a logic error. Perhaps this
never took effect, but with $forward_attachments it now affects
forwarding in that case.
Kevin McCarthy [Sat, 25 May 2019 20:12:04 +0000 (13:12 -0700)]
Have $forward_attachments look at attachment disposition.
If $honor_disposition is set, an "attachment" disposition decodable
attachment won't be included in the body, so we want it to be added as
an attachment to the forwarded email.
Kevin McCarthy [Mon, 20 May 2019 19:32:37 +0000 (12:32 -0700)]
Make mutt.texi and mutt.info generation continue on failure.
Add warning messages, noting the appropriate packages to install.
Note: mutt.texi won't normally be built unless configure finds one of
the possible expected conversion program names. Unfortunately, the
canonical name, "docbook2texi", is used by both the docbook2x and
docbook-utils projects.
So on Arch, the canonical name is what we need, while on Debian and
Red Hat/Fedora it isn't. We search for the alternative names first,
but it's still possible to invoke the wrong program if the needed
package is not installed.
Kevin McCarthy [Sun, 19 May 2019 21:40:08 +0000 (14:40 -0700)]
Adjust docbook2texi program search.
Look for db2x_docbook2texi first, because Fedora/Red Hat has their own
version of "docbook2texi": db2x_docbook2texi. I'm not sure what to do
if they have don't have that installed but have docbook2texi
installed, since this is a terrible name collision.
Thanks to Moritz Barsnick for pointing out the different binary (and
package) names on Fedora.
Kevin McCarthy [Sun, 19 May 2019 17:14:09 +0000 (10:14 -0700)]
Update gpgme and gpg-error automake checks.
Pull updated autoconf files from the GPGME 1.13.0 release and use
those new macros.
Add a call to AM_PATH_GPG_ERROR() and include $(GPG_ERROR_LIBS) in the
libraries.
Thanks to Eike Rathke for finding the build problem, and for his
patch fixing the issue. I opted for just grabbing the newest autoconf
files from gpgme instead, but his fixed worked great too.
Vincent Lefevre [Wed, 15 May 2019 11:05:09 +0000 (13:05 +0200)]
Avoid undefined behavior on huge integer in a RFC 2231 header.
The atoi() function was called on the index, which can potentially
be huge in an invalid message and can yield undefined behavior. The
mutt_atoi() function is now used for error detection.
Kevin McCarthy [Fri, 10 May 2019 02:21:34 +0000 (19:21 -0700)]
Check for NULL addresses in mutt_addrcmp().
While looking into ticket #140, I noticed default_to() could pass a
NULL env->from to mutt_addrcmp() if $reply_self is set and there is a
reply_to address.
Kevin McCarthy [Thu, 9 May 2019 20:25:25 +0000 (13:25 -0700)]
Change sample muttrc path to match other manual references.
The other parts of the manual refer to /usr/local/share/doc in their
examples. For consistency, change the starter muttrc and manual entry
to do the same.
In the future, we may wish to have a config variable instead, so users
don't have to worry about system vs locally installed paths when
sourcing the gpg.rc, for instance.
Kevin McCarthy [Thu, 2 May 2019 19:31:29 +0000 (12:31 -0700)]
Write rfc2231 parameter continuations for long parameters.
Previously, Mutt would truncate long attachment filenames, to avoid
writing an illegal length header line. This commit is a followup to 4dcb3ba1, where I reverted an incorrect fix for the problem.
rfc2231_encode_string() now returns a list of continuations, with
encoding and continuation number suffixes already appended to the
attribute. The function tries to keep the line length less than 78
characters, but the code is a bit imprecise as a trade off for
simplicity and readability.
Modify mutt_write_mime_header() to loop through the continuations.
Kevin McCarthy [Sun, 28 Apr 2019 22:48:33 +0000 (15:48 -0700)]
Fix mailbox search to not recompile for a repeated search.
The LastSearchExpn was being compared, but was never set to the
expanded search value. This was causing the search to be recompiled
even if it were for the same previous expanded search string.
Kevin McCarthy [Fri, 26 Apr 2019 02:41:04 +0000 (19:41 -0700)]
Add $forward_attachments quadoption for inline-forward mode.
When set or answered yes, non text-decodable parts will be attached to
the new message. The default value is "ask-yes", because I believe
this is something people will want to use, and should be made aware of
the new possible behavior.
The option presents a nice middle ground between previous
inline-forwarding behavior (where all the non-text parts were
dropped), and $mime_forward where the entire email was included as an
attachment.
This was previously difficult to achieve, but after the
recv-attachment refactoring: (a19e5266^..faabd621)
it became possible to use the ATTACH_CONTEXT and the recvattach.c
helper mutt_generate_recvattach_list() to properly deal with nesting
and multiple file-handles.
Kevin McCarthy [Wed, 24 Apr 2019 02:06:11 +0000 (19:06 -0700)]
Add RECURSIVEMATCH LIST-EXTENDED selection option to query.
LSUB is required to include mailboxes with subscribed children, but
the just added "LIST (SUBSCRIBED)" by default does not do that.
To match previous behavior, add RECURSIVEMATCH to make sure the
children are included. Fix the parser to trim off the CHILDINFO
suffix in the response.
Parse \NonExistent LIST attribute the same as \NoSelect.
Improve hierarchy information accuracy in IMAP browser
Currently the IMAP browser relies on LIST and LSUB (for listing subscribed
folders) which may not provide the required hierarchy information.
RFC3348 section 3 goes as far as stating that a client mustn't rely on LSUB
for hierarchy information.
This patch implements the LIST command extensions specified in RFC5258
requiring that a server must respond with hierarchy information for
listed folders (whether or not filtering on subscribed folders).
Kevin McCarthy [Sun, 19 Aug 2018 16:25:53 +0000 (09:25 -0700)]
Add $imap_fetch_chunk_size to allow FETCHing new headers in chunks.
For extremely large mailboxes, some implementations will time out just
while fetching the new headers, because the client doesn't send any
commands for 30 minutes while downloading the large number of headers.
Rewrite imap_fetch_msn_seqset() to return chunks of size
$imap_fetch_chunk_size.
The change requires trusting the server will follow the RFC and not
send an EXPUNGE during or between the FETCH chunks; otherwise we'll
miss MSNs between the chunks because the shift.
We could in theory continue to set "msn_begin = idata->max_msn + 1",
but that makes the assumption there are no holes in the header cache
that we are filling in during a chunk. Personally I am dubious about
"header cache holes", but the IMAP code has explicitly mentioned and
handled them since prior to my involvement.
Since the RFC forbids the interleaving EXPUNGE I believe it's safe
enough to set "msn_begin = fetch_msn_end + 1" until proven otherwise.
Kevin McCarthy [Sun, 21 Apr 2019 18:00:23 +0000 (11:00 -0700)]
Fix unistring library configure test.
The "action-if-found" argument of AC_SEARCH_LIBS is run even if the
result is "none required" (i.e. the test function is already in LIBS,
in this case -lidn2).
This was causing "-lunistring" to be appended on a system without the
library installed, generating a build error. Fix the test to not
append the library for the "none required" case.
Thanks to Fabrice Fontaine for reporting this issue and helping me
test the fix.
Kevin McCarthy [Sat, 20 Apr 2019 19:34:35 +0000 (12:34 -0700)]
Convert compress to use mutt_buffer_quote_filename().
Because the compress expandos operate differently than the rest of
mutt, requiring manual outer quoting, add a parameter to the function
to toggle outer quoting off.
Kevin McCarthy [Fri, 19 Apr 2019 23:06:43 +0000 (16:06 -0700)]
Increase mutt_pgpring path size to silence warning.
This is an independent binary, and doesn't have access to the BUFFER
functions. The binary is used by very few (if any) people at this
point, so just make the minimum fix to silence the warning.
Kevin McCarthy [Thu, 18 Apr 2019 22:35:22 +0000 (15:35 -0700)]
Relocate lib.c functions to muttlib.c to enable BUFFER use.
Relocate safe_symlink(), safe_open(), mutt_rmtree() and their
dependent functions.
This rearrangement is a bit awkward. Another approach for the future
might be to convert lib.c into a muttlib.c aware file, and just copy
the functions pgppubring.c uses inside itself.
Kevin McCarthy [Wed, 17 Apr 2019 01:11:35 +0000 (18:11 -0700)]
Convert other users of BUFFY->pathbuf to use BUFFERS.
A few functions in browser.c, buffy.c, and monitor.c were using
BUFFY->pathbuf but were potentially truncating via fixed size buffers.
Convert those to use BUFFERS too.
buffy_get() was creating epath and expanding it, apparently to match
against expanded BUFFY list entries, was wasn't using the epath. I
believe this is a bug, and have switched the comparison to epath.
Kevin McCarthy [Tue, 16 Apr 2019 20:41:10 +0000 (13:41 -0700)]
Convert BUFFER->path to a BUFFER.
Rename to BUFFER->pathbuf to make it clear the field is a BUFFER, and
to make sure to catch and review all usages.
There are still uses of pathbuf that are truncating and need to be
fixed, for example in browser.c and buffy.c.
Fix up sidebar usage in one place, that was pointing inside the
BUFFY->path with a char *. At the same time, change their "short
folder" computation to also use a BUFFER.
Switch to generating the version string during make process rather than
at configure time. This makes it easier to keep the detailed version
string accurate when doing development which doesn't require that the
configure script be rerun.
Kevin McCarthy [Wed, 10 Apr 2019 00:52:14 +0000 (17:52 -0700)]
Convert mutt_expand_fmt() and rfc1524_expand_filename() to BUFFER.
These two functions were tied together and so are converted at the
same time.
Note that rfc1524_expand_filename() had an off-by-one error for the
left hand size of the name template. It was only copying i-1 instead
of the i characters before %s.