removeJournal should restore LF characters

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2022-05-11 11:20:26 +02:00
parent 79bf09fd53
commit d1b0df1b41

View File

@ -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;