From aa01343df87d834cd969847a506b6f55c7ab5890 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 17 Oct 2022 11:30:32 +0200 Subject: [PATCH] Resolve #555 --- .../0.0.0/app/libraries/MailSo/Base/Utils.php | 11 ---------- .../app/libraries/MailSo/Mime/Header.php | 20 +++++++------------ 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Base/Utils.php b/snappymail/v/0.0.0/app/libraries/MailSo/Base/Utils.php index 1d091b6da..aedc2625b 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Base/Utils.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Base/Utils.php @@ -1008,17 +1008,6 @@ abstract class Utils // && \is_callable($mFunctionNameOrNames); } - public static function CharsetDetect(string $sStr) : string - { - $mResult = ''; - if (!static::IsAscii($sStr)) - { - $mResult = \mb_detect_encoding($sStr, 'auto', true); - } - - return \is_string($mResult) && \strlen($mResult) ? $mResult : ''; - } - public static function Sha1Rand(string $sAdditionalSalt = '') : string { return \sha1($sAdditionalSalt . \random_bytes(16)); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Header.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Header.php index a0f58dc29..1a5638489 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Header.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/Header.php @@ -226,20 +226,14 @@ class Header public function ValueWithCharsetAutoDetect() : string { - $sValue = $this->Value(); - if (!\MailSo\Base\Utils::IsAscii($sValue) && - \strlen($this->sEncodedValueForReparse) && - !\MailSo\Base\Utils::IsAscii($this->sEncodedValueForReparse)) - { - $sValueCharset = \MailSo\Base\Utils::CharsetDetect($this->sEncodedValueForReparse); - if (\strlen($sValueCharset)) - { - $this->SetParentCharset($sValueCharset); - $sValue = $this->Value(); - } + if (!\MailSo\Base\Utils::IsAscii($this->Value()) + && \strlen($this->sEncodedValueForReparse) + && !\MailSo\Base\Utils::IsAscii($this->sEncodedValueForReparse) + && ($mEncoding = \mb_detect_encoding($this->sEncodedValueForReparse, 'auto', true)) + ) { + $this->SetParentCharset($mEncoding); } - - return $sValue; + return $this->Value(); } public function IsReparsed() : bool