This commit is contained in:
the-djmaze 2022-10-17 11:30:32 +02:00
parent b011d1fa0e
commit aa01343df8
2 changed files with 7 additions and 24 deletions

View file

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

View file

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