]> granicus.if.org Git - neomutt/commitdiff
Decode CRLF line endings to LF when copying headers 606/head
authorJulian Andres Klode <jak@jak-linux.org>
Sat, 3 Jun 2017 15:43:09 +0000 (17:43 +0200)
committerRichard Russon <rich@flatcap.org>
Sat, 24 Jun 2017 11:06:47 +0000 (12:06 +0100)
This fixes display issues with files that consist of CRLF
line endings rather than just LF line endings, for example,
emails exported directly from the gmail API.

This only kicks in when CH_DECODE is set which might be a bit
strange, because that does RFC2047 header decoding, but it seems
a safe place to place this line end decoding without potentially
affecting anything else.

copy.c

diff --git a/copy.c b/copy.c
index 0ed3e0b8a64d239fc73f2140cd11f13120a2a3b7..608f56522b5fd2c3f0ba47206db00aae151a236b 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -181,6 +181,14 @@ int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
           if (!address_header_decode(&this_one))
             rfc2047_decode(&this_one);
           this_one_len = mutt_strlen(this_one);
+
+          /* Convert CRLF line endings to LF */
+          if ((this_one_len > 2) && (this_one[this_one_len - 2] == '\r') &&
+              (this_one[this_one_len - 1] == '\n'))
+          {
+            this_one[this_one_len - 2] = '\n';
+            this_one[this_one_len - 1] = 0;
+          }
         }
 
         if (!headers[x])