From 13b41b44c0fa2c04af4712044542913578e8679c Mon Sep 17 00:00:00 2001 From: djmaze Date: Mon, 30 Nov 2020 10:50:30 +0100 Subject: [PATCH] Change: force CRLF due to hMailserver bug https://github.com/the-djmaze/snappymail/issues/43 https://github.com/hmailserver/hmailserver/issues/357 --- .../app/libraries/MailSo/Base/HtmlUtils.php | 1 - .../app/libraries/MailSo/Mime/Message.php | 32 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php b/snappymail/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php index feafede9a..6d35b4ea9 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Base/HtmlUtils.php @@ -1113,7 +1113,6 @@ abstract class HtmlUtils public static function ConvertHtmlToPlain(string $sText) : string { - $sText = \trim(\stripslashes($sText)); $sText = \MailSo\Base\Utils::StripSpaces($sText); $sText = \preg_replace(array( diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Message.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Message.php index a3e7bc164..7b91656d0 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Message.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Message.php @@ -20,12 +20,12 @@ class Message /** * @var array */ - private $aHeadersValue; + private $aHeadersValue = array(); /** * @var array */ - private $aAlternativeParts; + private $aAlternativeParts = array(); /** * @var AttachmentCollection @@ -35,20 +35,16 @@ class Message /** * @var bool */ - private $bAddEmptyTextPart; + private $bAddEmptyTextPart = true; /** * @var bool */ - private $bAddDefaultXMailer; + private $bAddDefaultXMailer = true; function __construct() { - $this->aHeadersValue = array(); - $this->aAlternativeParts = array(); $this->oAttachmentCollection = new AttachmentCollection; - $this->bAddEmptyTextPart = true; - $this->bAddDefaultXMailer = true; } public function DoesNotCreateEmptyTextPart() : self @@ -325,16 +321,12 @@ class Message public function AddPlain(string $sPlain) : self { - return $this->AddAlternative( - Enumerations\MimeType::TEXT_PLAIN, trim($sPlain), - \MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER); + return $this->AddAlternative(Enumerations\MimeType::TEXT_PLAIN, $sPlain); } public function AddHtml(string $sHtml) : self { - return $this->AddAlternative( - Enumerations\MimeType::TEXT_HTML, trim($sHtml), - \MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER); + return $this->AddAlternative(Enumerations\MimeType::TEXT_HTML, $sHtml); } public function AddText(string $sHtmlOrPlainText, bool $bIsHtml = false) : self @@ -342,10 +334,14 @@ class Message return $bIsHtml ? $this->AddHtml($sHtmlOrPlainText) : $this->AddPlain($sHtmlOrPlainText); } - public function AddAlternative(string $sContentType, $mData, string $sContentTransferEncoding = '', array $aCustomContentTypeParams = array()) : self + public function AddAlternative(string $sContentType, string $sData) : self { - $this->aAlternativeParts[] = array($sContentType, $mData, $sContentTransferEncoding, $aCustomContentTypeParams); - + $this->aAlternativeParts[] = array( + $sContentType, + \preg_replace('/\\r?\\n/', Enumerations\Constants::CRLF, \trim($sData)), + \MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER, + array() + ); return $this; } @@ -531,7 +527,7 @@ class Message private function createNewMessageSimpleOrAlternativeBody() : Part { $oResultPart = null; - if (1 < count($this->aAlternativeParts)) + if (1 < \count($this->aAlternativeParts)) { $oResultPart = new Part;