Kevin McCarthy [Wed, 13 Sep 2017 22:48:16 +0000 (15:48 -0700)]
Change imap copy/save and trash to sync flags, excluding deleted. (closes #3966) (closes #3860)
imap_copy_messages() uses a helper to sync the flags before performing
a server-side copy. However, it had a bug that the "deleted" flag on
a local message, if set, will be propagated to the copy too.
Change the copy sync helper to ignore the deleted flag. Then, change
the imap trash function to use the same helper.
Thanks to Anton Lindqvist for his excellent bug report, suggested
fixes, and help testing.
Kevin McCarthy [Wed, 13 Sep 2017 22:48:13 +0000 (15:48 -0700)]
Remove \Seen flag setting for imap trash. (see #3966) (see #3860)
Commit 323e3d6e5e4c has a side effect where spurious FETCH flag
updates after setting the \Seen flag can cause a sync to abort.
Remove manually setting \Seen for all trashed message before copying.
The next commit will change the imap trash function to use the same
code as the imap copy/save function for syncing the message before
server-side copying.
Kevin McCarthy [Sat, 2 Sep 2017 16:36:52 +0000 (09:36 -0700)]
Fix the new certificate prompt translations.
The Esperanto, Dutch, and Czech po files weren't updated in time for
1.9. Fix the certificate prompt translations by adding a "(s)kip"
choice. Otherwise the prompts would not be functional.
Kevin McCarthy [Fri, 11 Aug 2017 16:04:48 +0000 (09:04 -0700)]
Fix parent_hdr usage in mutt_attach_reply(). (see #3728)
If the selected attachments are not messages and no (common) parent is
found, parent_hdr is set to the passed in hdr. In that case, parent
will still be NULL, but parent_hdr and parent_fp will be set.
Change the test to parent_hdr being NULL, not parent, to check for
this case.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:28 +0000 (18:18 -0700)]
Add edit-content-type helper and warning for decrypted attachments. (closes #3728)
Regenerating the actx index will overwrite any changes made to a
decrypted attachment. Change the mutt_edit_content_type() function to
return 1 when a structural change is made. Add a warning message when
that is the case and a decrypted message was edited, so the user is
not surprised.
Note: mutt_edit_content_type() appeared to regenerate multipart
subparts every time, leading to a memory leak. I believe this was an
oversite, and it should have regenerated only when there were no
subparts, so have "fixed" this.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:25 +0000 (18:18 -0700)]
Fix shared attachment functions. (see #3728)
With nested decryption, the correct FP is associated with the
ATTACHPTR entry. Also, the BODY entries are not continguous, so the
functions need to iterate over the actx index, not the BODY structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:20 +0000 (18:18 -0700)]
Add helpers to add and remove actx entries. (see #3728)
Use the helper in compose update_idx(), to consolidate the resize
logic and simplify the code.
Separate out the actx "free" routine from a routine to empty out the
idx. The index regeneration routines should flush and rebuild the
index without having to renerate the actx structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:18 +0000 (18:18 -0700)]
Create ATTACH_CONTEXT to hold attachment index. (see #3728)
Move the idx and idxlen into ATTACH_CONTEXT. In subsequence patches,
this structure will hold more useful items, such as the virtual index.
The swap out is straightforward, except for:
* update_idx() in compose.c, which post-increments the idxlen in the
call and again in the function.
* mutt_gen_attach_list() which doesn't need to returns the new values.
Kevin McCarthy [Sun, 23 Jul 2017 02:48:50 +0000 (19:48 -0700)]
Add $imap_poll_timeout to allow mailbox polling to time out.
Enable the polling flag for the NOOP in imap_check_mailbox(), the
STATUS command in imap_buffy_check(), and the LOGOUT command.
This is not intended to handle all blocking-IO related issues.
However, the periodic NOOP and STATUS are the most frequent places for
mutt to freeze up, especially after a laptop is sleep/woken.
Since these are quick operations with little data, this is a good place
to check if the connection is still working before hanging on a read.
Kevin McCarthy [Fri, 21 Jul 2017 00:30:05 +0000 (17:30 -0700)]
When guessing an attachment type, don't allow text/plain if there is a null character. (see #2933)
Type text/plain should not contain any null characters. Slightly
improve the type guesser by forcing an attachment with any null
characters to be application/octet-stream.
Note the type guesser could use much more improvement, but this is an
easy and obvious fix.
Kevin McCarthy [Wed, 19 Jul 2017 21:04:39 +0000 (14:04 -0700)]
Change imap_cmd_start() to return OK when the cmd_queue is finished. (closes #3956)
Some response handlers can end up recursively calling
imap_cmd_start(), processing all the command completions. If the
outer call was an imap_exec(), this would result in the loop never
being terminated (or just blocking reading a server that has already
finished all the commands).
Change the callers that are simply using it to read a response,
without having called cmd_start(), to check for IMAP_CMD_OK instead.
Currently this is just the open connection function.
When using alloca(), the built-in regexp library limited the failure
stack to 20,000 entries. This value is too large, and causes alloca()
to segfault in the example provided in the ticket.
Decrease the limit to 8000.
Thanks to Thorsten Wißmann for the excellent bug report, which made
debugging this much easier.
Kevin McCarthy [Wed, 12 Jul 2017 19:38:22 +0000 (12:38 -0700)]
Fix crash when $postponed is on another server.
imap_mxcmp() translates NULL to "INBOX". When $postponed points to a
URL with an empty or "INBOX" path, this will end up matching against a
NULL idata->mailbox in imap_status(). This resulted in a crash
because idata->ctx is also NULL.
Thanks to Olaf Hering for the detailed bug report and suggested fix.
Kevin McCarthy [Wed, 14 Jun 2017 22:12:45 +0000 (15:12 -0700)]
Enable all header fields in the compose menu to be translated.
While it is suggested they need not be, for some locales it might be
preferable to be able to localize the fields.
For instance, fr_FR may want to change the punctuation to have a space
in front of the colon. ja_JP may be more comfortable with a native
character set description of the field when using it every day.
Kevin McCarthy [Tue, 13 Jun 2017 01:29:48 +0000 (18:29 -0700)]
Force hard redraw after $sendmail instead of calling mutt_endwin. (closes #3952) (see #3948)
Adding a mutt_endwin() seemed like a clean solution to allowing
ncurses pinentry for $sendmail, but it leaves other users watching a
blank screen. This change is extremely likely to generate a large
number of complaints and bug reports. So instead, force a hard
refresh afterwards.
Vincent expressed some legitimate concerns about exporting this to all
programs lauched by mutt. The user can always set GPG_TTY in their
.bashrc if needed for $sendmail. cf90bf5989f3 should resolve the
refresh issue.
Kevin McCarthy [Wed, 7 Jun 2017 01:38:47 +0000 (18:38 -0700)]
Add a mutt_endwin() before invoking $sendmail. (closes #3948)
This is to support invoking a program such as msmtp that can use gpg
to decrypt a password. The ncurses pinentry can corrupt the screen
unless we exit curses.
Kevin McCarthy [Thu, 1 Jun 2017 22:17:01 +0000 (15:17 -0700)]
Change km_dokey() to return -2 on a timeout/sigwinch.
In some cases, such as tag-prefix or _mutt_enter_string(), it is
desirable to be able to distinguish between a timeout/sigwinch event
and an input error/abort/ctrl-g.
Kevin McCarthy [Wed, 31 May 2017 23:18:29 +0000 (16:18 -0700)]
Add note about message scoring and thread patterns. (see #3947)
Because scoring occurs before the mailbox is sorted, thread patterns
don't work. Document a suggested workaround of pushing the score
command in a folder hook.
Also, fix the link target for the score command synopsis.
Kevin McCarthy [Mon, 29 May 2017 18:48:43 +0000 (11:48 -0700)]
Change $postpone_encrypt to use self-encrypt variables first.
The concept of postpone encryption is similar to self-encrypting on
send. The problem is the $postpone_encrypt_as option doesn't take
into account whether PGP or S/MIME is being used.
Since we need to add the new options for self-encryption, modify
$postpone_encrypt to use them by default instead, falling back to
$postpone_encrypt_as if they are unset. Note $postpone_encrypt_as is
deprecated in the documentation.
$pgp_sign_as and $smime_default_key are inappropriate to use, as they
specify signing key/certs. In some cases, this is a different value
than the encryption key/cert.
Kevin McCarthy [Mon, 29 May 2017 18:48:41 +0000 (11:48 -0700)]
Convert classic s/mime to space delimit findKeys output.
Unlike gpgme and classic pgp, smime used a "cert\ncert\n" pattern.
Convert to use a space-delimited format, so the self-encrypt option
code can be uniform across pgp, s/mime, and gpgme.
Kevin McCarthy [Tue, 23 May 2017 22:53:30 +0000 (15:53 -0700)]
Fix memory leak when closing mailbox and using the sidebar.
The code updating the sidebar counts decremented the msgcount, but did
not set it back to the original value. Which means fastclose was not
freeing all the headers.
Update the sidebar only when something is deleted, since I don't
believe it's required otherwise and the code is a bit cleaner that
way.
Kevin McCarthy [Mon, 22 May 2017 11:43:24 +0000 (04:43 -0700)]
Fix mfc overflow check and uninitialized variable.
The check borrowed from mx_alloc_memory() works because it is
incremented 25 at a time. I don't believe it will work for the direct
set case used in imap_alloc_msn_index(). Instead, use a more
conservative check.
In imap_read_headers(), make sure mfhrc is initialized. It would be
tested without being set if imap_cmd_step() returned OK right away.
Kevin McCarthy [Mon, 22 May 2017 01:45:08 +0000 (18:45 -0700)]
Small imap fetch fixes. (see #3942)
Add an integer overflow test, pulled from mx_alloc_memory(), since the
count comes from a potentially hostile server.
After reviewing the RFC a bit, it turns out the server is not supposed
to send EXPUNGE responses during a FETCH. Change the comment, but
keep the conservative code.
Kevin McCarthy [Sun, 21 May 2017 17:51:38 +0000 (10:51 -0700)]
Properly adjust fetch ranges when handling new mail. (see #3942)
When pulling down headers, it is possible for expunge responses to
happen too. If we get a new mail count, we need to take into account
changes to the max_msn due to the expunges.
Kevin McCarthy [Sun, 21 May 2017 01:52:18 +0000 (18:52 -0700)]
Add msn_index and max_msn to find and check boundaries by MSN. (see #3942)
Since there can be gaps in MSNs, the largest MSN in the context is not
necessarily ctx->msgcount.
Use max_msn instead of ctx->msgcount for:
- the starting MSN of new mail header fetching
- boundary checking in fetch, expunge, and other places
Use msn_index to efficiently look up headers by MSN. This makes the
expunge code slightly more efficient. It also makes FETCH handling, and
duplicate FETCH FLAG handling efficient.
Kevin McCarthy [Sun, 21 May 2017 01:52:16 +0000 (18:52 -0700)]
Start fixing imap_read_headers() to account for MSN gaps. (see #3942)
Change the parameters to pass MSN instead of index, to make a bit
simpler.
Change header cache evaluation to look at the largest MSN retrieved
instead of ctx->msgcount for the next fetch start point. This still
depends on the assumption that MSNs are retrieved in ascending order,
which needs to be fixed.
Simplify the header cache inner loop termination and memory cleanup
logic. Fix a memory leak if a hole in the header cache occured.
Fix the header retrieval logic to take into account MSN gaps in the
results. Loop only as long as we get IMAP_CMD_CONTINUE instead of
over a fixed count. Simplify the inner loop termination and memory
cleanup logic too.
Simplify the "new mail while fetching" logic by creating a third outer
loop to handle re-fetches.
Fix msg_fetch_header() to return -2 if msg_parse_fetch() encounters a
corrupt FETCH response. Previously it would pass on the rc of
msg_parse_fetch(), meaning it would return -1 even though the response
was corrupt.