mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-28 02:21:06 +08:00
Fixed MailSo header parsing
This commit is contained in:
parent
ccbf04cb67
commit
77870442fe
5 changed files with 29 additions and 9 deletions
|
@ -43,6 +43,11 @@ class Config
|
|||
*/
|
||||
public static $MessageListDateFilter = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $LogSimpleLiterals = false;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Log\Logger|null
|
||||
*/
|
||||
|
|
|
@ -1929,10 +1929,15 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$this->writeLog('Literal stream read warning "read '.$iLiteralSize.' of '.
|
||||
$iLiteralLen.'" bytes', \MailSo\Log\Enumerations\Type::WARNING);
|
||||
}
|
||||
|
||||
|
||||
if (!$bTreatAsAtom)
|
||||
{
|
||||
$aList[] = $sLiteral;
|
||||
|
||||
if (\MailSo\Config::$LogSimpleLiterals)
|
||||
{
|
||||
$this->writeLog('{'.\strlen($sLiteral).'} '.$sLiteral, \MailSo\Log\Enumerations\Type::INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -619,7 +619,7 @@ class Message
|
|||
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
|
||||
if (0 < \strlen($sHeaders))
|
||||
{
|
||||
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders);
|
||||
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders, false, $sCharset);
|
||||
|
||||
$sContentTypeCharset = $oHeaders->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
|
|
|
@ -44,10 +44,11 @@ class Header
|
|||
* @param string $sName
|
||||
* @param string $sValue
|
||||
* @param string $sEncodedValueForReparse
|
||||
* @param string $sParentCharset = ''
|
||||
*/
|
||||
private function __construct($sName, $sValue, $sEncodedValueForReparse)
|
||||
private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '')
|
||||
{
|
||||
$this->sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
|
||||
$this->sParentCharset = $sParentCharset;
|
||||
|
||||
$this->initInputData($sName, $sValue, $sEncodedValueForReparse);
|
||||
}
|
||||
|
@ -95,12 +96,13 @@ class Header
|
|||
* @param string $sName
|
||||
* @param string $sValue = ''
|
||||
* @param string $sEncodedValueForReparse = ''
|
||||
* @param string $sParentCharset = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Header
|
||||
*/
|
||||
public static function NewInstance($sName, $sValue = '', $sEncodedValueForReparse = '')
|
||||
public static function NewInstance($sName, $sValue = '', $sEncodedValueForReparse = '', $sParentCharset = '')
|
||||
{
|
||||
return new self($sName, $sValue, $sEncodedValueForReparse);
|
||||
return new self($sName, $sValue, $sEncodedValueForReparse, $sParentCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,13 +113,19 @@ class Header
|
|||
*/
|
||||
public static function NewInstanceFromEncodedString($sEncodedLines, $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1)
|
||||
{
|
||||
if (empty($sIncomingCharset))
|
||||
{
|
||||
$sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
|
||||
}
|
||||
|
||||
$aParts = \explode(':', \str_replace("\r", '', $sEncodedLines), 2);
|
||||
if (isset($aParts[0]) && isset($aParts[1]) && 0 < \strlen($aParts[0]) && 0 < \strlen($aParts[1]))
|
||||
{
|
||||
return self::NewInstance(
|
||||
\trim($aParts[0]),
|
||||
\trim(\MailSo\Base\Utils::DecodeHeaderValue(\trim($aParts[1]), $sIncomingCharset)),
|
||||
\trim($aParts[1])
|
||||
\trim($aParts[1]),
|
||||
$sIncomingCharset
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -167,7 +175,8 @@ class Header
|
|||
$this->initInputData(
|
||||
$this->sName,
|
||||
\trim(\MailSo\Base\Utils::DecodeHeaderValue($this->sEncodedValueForReparse, $sParentCharset)),
|
||||
$this->sEncodedValueForReparse);
|
||||
$this->sEncodedValueForReparse
|
||||
);
|
||||
}
|
||||
|
||||
$this->sParentCharset = $sParentCharset;
|
||||
|
|
|
@ -29,7 +29,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
parent::__construct();
|
||||
|
||||
$this->sRawHeaders = '';
|
||||
$this->sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1;
|
||||
$this->sParentCharset = '';
|
||||
|
||||
if (0 < \strlen($sRawHeaders))
|
||||
{
|
||||
|
@ -318,6 +318,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
{
|
||||
$this->Add($oHeader);
|
||||
}
|
||||
|
||||
$sName = null;
|
||||
$sValue = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue