From af725fe7d5b5ba2d22d322c470c092d32d04e242 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 3 Jun 2017 17:43:09 +0200 Subject: [PATCH] Decode CRLF line endings to LF when copying headers 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/copy.c b/copy.c index 0ed3e0b8a..608f56522 100644 --- 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]) -- 2.40.0