summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-12-27 12:05:43 -0800
committerKevin McCarthy <kevin@8t8.us>2018-12-29 14:12:07 -0800
commit333312c22e762169500949583755b6e208fc23e5 (patch)
treee620bcb1f72ffb690c880c60e33ad1c4700a55ef /copy.c
parent2817372ffb68c46f68d14d844b913204f9c7dccc (diff)
Add $crypt_protected_headers_save.
Setting this option will save the protected header back into the clear-text message headers. This improves usability (searching/limiting/replying) when reopening a mailbox without header cache. However, it is a security trade-off, so defaults off and strongly warns about what it is doing in the documentation.
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/copy.c b/copy.c
index fa1240ab..2b0df8a6 100644
--- a/copy.c
+++ b/copy.c
@@ -111,6 +111,9 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
if ((flags & CH_UPDATE_LABEL) &&
ascii_strncasecmp ("X-Label:", buf, 8) == 0)
continue;
+ if ((flags & CH_UPDATE_SUBJECT) &&
+ ascii_strncasecmp ("Subject:", buf, 8) == 0)
+ continue;
ignore = 0;
}
@@ -221,6 +224,9 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
if ((flags & CH_UPDATE_LABEL) &&
ascii_strncasecmp ("X-Label:", buf, 8) == 0)
continue;
+ if ((flags & CH_UPDATE_SUBJECT) &&
+ ascii_strncasecmp ("Subject:", buf, 8) == 0)
+ continue;
/* Find x -- the array entry where this header is to be saved */
if (flags & CH_REORDER)
@@ -357,7 +363,8 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
if (h->env)
flags |= ((h->env->changed & MUTT_ENV_CHANGED_IRT) ? CH_UPDATE_IRT : 0)
| ((h->env->changed & MUTT_ENV_CHANGED_REFS) ? CH_UPDATE_REFS : 0)
- | ((h->env->changed & MUTT_ENV_CHANGED_XLABEL) ? CH_UPDATE_LABEL : 0);
+ | ((h->env->changed & MUTT_ENV_CHANGED_XLABEL) ? CH_UPDATE_LABEL : 0)
+ | ((h->env->changed & MUTT_ENV_CHANGED_SUBJECT) ? CH_UPDATE_SUBJECT : 0);
if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
return -1;
@@ -444,6 +451,25 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
FREE (&temp_hdr);
}
+ if ((flags & CH_UPDATE_SUBJECT) && h->env->subject)
+ {
+ temp_hdr = h->env->subject;
+ /* env->subject is directly referenced in Context->subj_hash, so we
+ * have to be careful not to encode (and thus free) that memory. */
+ if (!(flags & CH_DECODE))
+ {
+ temp_hdr = safe_strdup (temp_hdr);
+ rfc2047_encode_string (&temp_hdr);
+ }
+ if (mutt_write_one_header (out, "Subject", temp_hdr,
+ flags & CH_PREFIX ? prefix : 0,
+ mutt_window_wrap_cols (MuttIndexWindow, Wrap),
+ flags) == -1)
+ return -1;
+ if (!(flags & CH_DECODE))
+ FREE (&temp_hdr);
+ }
+
if ((flags & CH_NONEWLINE) == 0)
{
if (flags & CH_PREFIX)