summaryrefslogtreecommitdiffstats
path: root/crypt.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-06-02 15:48:59 -0700
committerKevin McCarthy <kevin@8t8.us>2020-06-04 12:46:52 -0700
commit82b5c697e935ffe40b833e150aa79fd3cb27a20c (patch)
treeff6a499829ba43fc55eb2dbe84fc92abc4a778b6 /crypt.c
parentb0faa8d207d09ea25e2c7ed2083c74eac35458f2 (diff)
Add other headers to written Protected Headers.
In order to avoid $edit_headers, <resend-message>, or other places setting env->date and inadvertantly generating a wrong Date header, store the "protected headers" generated date header in the sctx, in addition to mime_headers. I initially removed env->date setting from mutt_parse_rfc822_line(), thinking it a more elegant solution, but unfortunately protected headers reading needs it to be there. We don't currently print or compare the headers, but might wish to in the future. Explicitly pass in a date parameters to mutt_write_rfc822_header() to make each caller conscious of where the date is coming from.
Diffstat (limited to 'crypt.c')
-rw-r--r--crypt.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/crypt.c b/crypt.c
index 314fdcdb..81e9b3d2 100644
--- a/crypt.c
+++ b/crypt.c
@@ -30,6 +30,7 @@
#include "mime.h"
#include "copy.h"
#include "mutt_crypt.h"
+#include "mutt_idna.h"
#ifdef USE_AUTOCRYPT
#include "autocrypt.h"
@@ -250,11 +251,25 @@ int mutt_protect (SEND_CONTEXT *sctx, char *keylist, int postpone)
if (option (OPTCRYPTPROTHDRSWRITE))
{
+ BUFFER *date = NULL;
protected_headers = mutt_new_envelope ();
- mutt_str_replace (&protected_headers->subject, msg->env->subject);
- /* Note: if other headers get added, such as to, cc, then a call to
- * mutt_env_to_intl() will need to be added here too. */
+
+ protected_headers->subject = safe_strdup (msg->env->subject);
+
+ /* Note that we set sctx->date_header too so the values match */
+ date = mutt_buffer_pool_get ();
+ mutt_make_date (date);
+ mutt_str_replace (&sctx->date_header, mutt_b2s (date));
+ protected_headers->date = safe_strdup (mutt_b2s (date));
+ mutt_buffer_pool_release (&date);
+
+ protected_headers->from = rfc822_cpy_adr (msg->env->from, 0);
+ protected_headers->to = rfc822_cpy_adr (msg->env->to, 0);
+ protected_headers->cc = rfc822_cpy_adr (msg->env->cc, 0);
+ protected_headers->reply_to = rfc822_cpy_adr (msg->env->reply_to, 0);
+
mutt_prepare_envelope (protected_headers, 0);
+ mutt_env_to_intl (protected_headers, NULL, NULL);
mutt_free_envelope (&msg->content->mime_headers);
msg->content->mime_headers = protected_headers;
@@ -377,6 +392,7 @@ cleanup:
{
mutt_free_envelope (&msg->content->mime_headers);
mutt_delete_parameter ("protected-headers", &msg->content->parameter);
+ FREE (&sctx->date_header);
}
if (sctx->pgp_sign_as)