From d1b0df1b41dbbd7c4b9e4c03967317e49739a6b7 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Wed, 11 May 2022 11:20:26 +0200 Subject: [PATCH] removeJournal should restore LF characters Signed-off-by: Janos SUTO --- webui/system/helper/mime.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webui/system/helper/mime.php b/webui/system/helper/mime.php index d50727de..9e5d5857 100644 --- a/webui/system/helper/mime.php +++ b/webui/system/helper/mime.php @@ -144,12 +144,22 @@ class Piler_Mime_Decode { public static function removeJournal(&$message, $EOL = "\n") { $has_journal = 0; + $crlfs = substr_count($message, "\r\n"); + self::splitMessageRaw($message, $headers, $journal, $body); if($journal) { $has_journal = 1; } + // If the message has >10 CRLF sequences, then we assume + // that we need to restore the removed LF characters + if($crlfs > 10) { + $headers = str_replace("\n", "\r\n", $headers); + $body = str_replace("\n", "\r\n", $body); + $EOL = "\r\n"; + } + $message = $headers . $EOL . $EOL . $body; return $has_journal;