emacs: use cached encoded copy for fcc

This fixes the bug reported by dkg in [1]. The movement of the call to
n-m-setup-message-for-saving is so the cleanup of Fcc headers happens
in the encoded version (otherwise Fcc headers may be saved to disk).

[1]: id:87k1zm225v.fsf@fifthhorseman.net
This commit is contained in:
David Bremner 2022-01-19 23:22:07 -04:00
parent 8179c3d114
commit da302e1cba
2 changed files with 6 additions and 3 deletions

View file

@ -149,6 +149,7 @@ Otherwise set it according to `notmuch-fcc-dirs'."
(buf (current-buffer))
(mml-externalize-attachments message-fcc-externalize-attachments))
(with-current-buffer (get-buffer-create " *message temp*")
(message-clone-locals buf) ;; for message-encoded-mail-cache
(erase-buffer)
(insert-buffer-substring buf)
,@body)))
@ -158,7 +159,10 @@ Otherwise set it according to `notmuch-fcc-dirs'."
This should be called on a temporary copy.
This is taken from the function message-do-fcc."
(message-encode-message-body)
(if (not message-encoded-mail-cache)
(message-encode-message-body)
(erase-buffer)
(insert message-encoded-mail-cache))
(save-restriction
(message-narrow-to-headers)
(mail-encode-encoded-word-buffer))
@ -179,12 +183,12 @@ This is a rearranged version of message mode's message-do-fcc."
(setq file (message-fetch-field "fcc" t)))
(when file
(with-temporary-notmuch-message-buffer
(notmuch-maildir-setup-message-for-saving)
(save-restriction
(message-narrow-to-headers)
(while (setq file (message-fetch-field "fcc" t))
(push file files)
(message-remove-header "fcc" nil t)))
(notmuch-maildir-setup-message-for-saving)
;; Process FCC operations.
(mapc #'notmuch-fcc-handler files)
(kill-buffer (current-buffer)))))))

View file

@ -21,7 +21,6 @@ test_expect_success \
"(mml-secure-message-sign)"'
test_begin_subtest "emacs delivery of signed message via fcc and smtp"
test_subtest_known_broken
emacs_deliver_message \
'signed message sent via SMTP' \
'This is a test that messages are sent via SMTP' \