]> granicus.if.org Git - neomutt/commitdiff
Rfc2047 encode and fold X-Label when writing updates
authorKevin McCarthy <kevin@8t8.us>
Fri, 28 Dec 2018 00:08:36 +0000 (16:08 -0800)
committerRichard Russon <rich@flatcap.org>
Mon, 7 Jan 2019 15:09:41 +0000 (15:09 +0000)
Also, add a missing "skip" in mutt_copy_hdr() for the non-simple case.

These fixes were backported from the kevin/mutt_protected_header branch.

Co-authored-by: Richard Russon <rich@flatcap.org>
copy.c

diff --git a/copy.c b/copy.c
index 4f8e2ff18c90f05e669de7fb4ab136ef213a35a4..5109009f4b5b81a376d8882ad00eeb305f1512df 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -502,12 +502,17 @@ int mutt_copy_header(FILE *in, struct Email *e, FILE *out, int flags, const char
   }
   FREE(&tags);
 
-  if (flags & CH_UPDATE_LABEL)
+  if ((flags & CH_UPDATE_LABEL) && e->env->x_label)
   {
-    e->xlabel_changed = false;
-    if (e->env->x_label)
-      if (fprintf(out, "X-Label: %s\n", e->env->x_label) != 10 + strlen(e->env->x_label))
-        return -1;
+    if (!(flags & CH_DECODE))
+      rfc2047_encode(&e->env->x_label, NULL, sizeof("X-Label:"), SendCharset);
+    if (mutt_write_one_header(out, "X-Label", e->env->x_label, flags & CH_PREFIX ? prefix : 0,
+                              mutt_window_wrap_cols(MuttIndexWindow, Wrap), flags) == -1)
+    {
+      return -1;
+    }
+    if (!(flags & CH_DECODE))
+      rfc2047_decode(&e->env->x_label);
   }
 
   if ((flags & CH_NONEWLINE) == 0)