Kevin McCarthy [Fri, 19 Jul 2019 19:54:32 +0000 (12:54 -0700)]
Add autocrypt line to the compose menu.
Remove the hardcoded HDR_ATTACH offset calcuation, and add an explicit
enum for the "-- Attachments" line to make loops and padding array
sizes easier.
Add security and recommendataion fields on the line.
Add mutt_autocrypt_ui_recommendation, following the autocrypt spec
guidelines.
Kevin McCarthy [Fri, 12 Jul 2019 01:06:56 +0000 (18:06 -0700)]
Add autocrypt header parsing to mutt_parse_rfc822_line().
Convert parse_parameters() for autocrypt header usage:
* change to use a BUFFER to accomodate large autocrypt keydata
attribute values.
* Autocrypt header parameters are not rfc2231 compliant. Rather
than rolling another very similar function, just change the
existing one to allow space separation.
Kevin McCarthy [Sun, 28 Jul 2019 17:13:22 +0000 (10:13 -0700)]
Add a comment to the OPTIGNOREMACROEVENTS km_dokey() change.
The option was added in commit 53900afa, and its actual purpose was
to separate out an "unget" event buffer from the "macro" buffer, to
solve a problem with certificate prompts.
The safest approach in a low-level function like km_dokey() was to
return an error if new macros were generated when the option is set.
However, this results in an unbuffered username/password prompt being
aborted.
Currently the only users of unbuffered input are the SSL certificate
prompts, which use menu->dialog mode (and thus mutt_getch() directly)
and username/password prompts. So the only affected cases are
editor-menu prompts, and returning the pressed keys is likely less
surprising than aborting the prompt.
If other unbuffered menus are created in the future, we may want to
add a check for which menu mode is being used.
Kevin McCarthy [Fri, 26 Jul 2019 01:18:08 +0000 (18:18 -0700)]
Fix accidental fall-through for <quote-char> if aborted.
If <quote-char> was aborted, it was falling through to the
<transpose-chars> function.
This problem was introduced 19 years when the <transpose-chars> case
was moved below <quote-char>. Previously it fell through to the
default case which beeped.
Andrew Marks [Fri, 5 Jul 2019 15:44:21 +0000 (08:44 -0700)]
Added * option to unattachments command
The * option clears all previous attachments settings. A
list_free_generic method is added to muttlib to enable generic freeing
of specific LIST structures. free_attachments_data is used with
list_free_generic to clear four LISTs which manage allowed and excluded
inline and attached "attachments"
The User-Agent: header can be fun and interesting and useful for
debugging, but it also leaks quite a bit of information about the user
and their software stack.
This represents a potential security risk (attackers can target the
particular stack) and also an anonymity risk (a user trying to
preserve their anonymity by sending mail from a non-associated account
might reveal quite a lot of information if their choice of mail user
agent is exposed).
Users who want to configure `user_agent` to `yes` can still do so, but
it makes sense to have safer defaults.
Kevin McCarthy [Thu, 27 Jun 2019 22:35:12 +0000 (15:35 -0700)]
Remove unnecessary "" checks for DT_STR and DT_PATH MuttVars.
MuttVars of those types are set via safe_strdup(), which returns NULL
if the original is "". Thus Var implies *Var.
A good portion of the code relies on that axiom, but over the years
some (Var && *Var) checks have crept in, including from me.
This was partially because of the INITVAL("") that were in the code,
which implied (incorrectly) the initial value could be "". Commit 2f91d43e removed those to make it more clear.
This commit removes the *Var checks to make it even clearer, and help
avoid them creeping back in again.
Kevin McCarthy [Thu, 27 Jun 2019 18:06:19 +0000 (11:06 -0700)]
Convert $header_cache_pagesize to type DT_LNUM.
Prior to commit 4bc76c2f there was no LNUM type, and so the workaround
was to store it as a string, converting in the hcache_open_gdbm()
call.
This will not affect the user interface or config file, because DT_NUM
and DT_LNUM read in a string from the config file and convert to a
number. Quotes are used for escaping style, not passed through to the
variable setter.
So essentially this simply moves the conversion to parse_set(), and
provides feedback for a non-numeric type immediately.
Kevin McCarthy [Tue, 25 Jun 2019 21:25:33 +0000 (14:25 -0700)]
Convert Commands to use the union pointer_long_t too.
As with MuttVars, Commands was using an unsigned long to hold pointers
as well as enums. Convert to use the same union type of MuttVars.
Adjust command functions data parameter type to the union. Since
these are used outside init.c, relocate the union definition to
mutt.h.
Although the number of functions affected was long, most of them did
not need much adjustment. Many of them made no use of the parameter.
Those that did were easily cast into an added "data" variable at the
top.
Kevin McCarthy [Tue, 25 Jun 2019 01:07:54 +0000 (18:07 -0700)]
Convert MuttVars.data and .init to use a union type.
They were using an "unsigned long" and casting to a pointer when
needed. Obviously this has "worked" for a long time, but it's not
correct to assume a pointer can fit in unsigned long.
Replace with a union contain "void *p" and "long l". Fortunately, the
only parts making direct use of MuttVars are in init.h and init.c, so
we just need to update those manipulation functions.
In general I don't like single letter variables, but brevity is worth
it in this case.
Kevin McCarthy [Sat, 22 Jun 2019 20:33:11 +0000 (13:33 -0700)]
Remove mutt_rfc1524_expand_filename() return value and checks.
The return value was of dubious value. It returned 0 only for the
case that a nametemplate was specified and it already matched the
supplied oldfile.
However, just because the nametemplate matched does not mean
attachment handling in send-mode should skip the mutt_adv_mktemp()
conversion, which includes a call to mutt_sanitize_filename(). We
didn't do so if *no* nametemplate was supplied.
Remove the return value from the function, and remove the checks and
"special handing" in attach.c calls.
Kevin McCarthy [Sat, 22 Jun 2019 19:54:40 +0000 (12:54 -0700)]
Remove unnecessary strcmp for mutt_view_attachment().
mutt_rfc1524_expand_filename() runs the result through
mutt_adv_mktemp(), which will sanitize and relocate the filename under
$tmpdir. The strcmp() is unneeded and distracting to the program
logic; none of the other routines perform or need this check.
Kevin McCarthy [Sat, 22 Jun 2019 17:09:02 +0000 (10:09 -0700)]
Fix send-mode printing when expand_filename() returns 1.
It will return this when a nametemplate entry already matched the
passed in filename. So this bug required both a print entry and an
already matching nametemplate entry to trigger.
Kevin McCarthy [Fri, 21 Jun 2019 20:28:11 +0000 (13:28 -0700)]
Remove UL "" initialization from init.h.
mutt_init() calls mutt_set_default() followed by
mutt_restore_default(). The mutt_restore_default() calls
mutt_str_replace(), which translates "" into 0.
Therefore assigning "" to the option->init field simply wastes space
and (incorrectly) implies the option->data will be non-NULL by default.
Kevin McCarthy [Tue, 11 Jun 2019 20:15:22 +0000 (13:15 -0700)]
Add $fcc_before_send, defaulting unset.
When set, the message will be Fcc'ed the same as sent. $fcc_clear and
$fcc_attach will be ignored. This is because of the difficulty of
unwinding changes, notably Protected Headers, without potentially
breaking signatures.
Kevin McCarthy [Mon, 10 Jun 2019 21:51:50 +0000 (14:51 -0700)]
Allow imap_cmd_finish() to both expunge and fetch new mail.
Since commit dd327606 changed check_status setting to use bit
operators, and imap_check_mailbox() can call imap_cmd_finish() twice,
there is no reason to delay the processing of new mail until a second
call.
imap_read_headers() deals with msn_end < msg_begin, so remove
the (count > idata->max_msn) check. This will allow the reopen flag
to be reset if somehow it's not the case.
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.