Fixed MailSo header parsing

This commit is contained in:
RainLoop Team 2014-09-02 13:54:22 +04:00
parent ccbf04cb67
commit 77870442fe
5 changed files with 29 additions and 9 deletions

View file

@ -43,6 +43,11 @@ class Config
*/
public static $MessageListDateFilter = 0;
/**
* @var int
*/
public static $LogSimpleLiterals = false;
/**
* @var \MailSo\Log\Logger|null
*/

View file

@ -1933,6 +1933,11 @@ class ImapClient extends \MailSo\Net\NetClient
if (!$bTreatAsAtom)
{
$aList[] = $sLiteral;
if (\MailSo\Config::$LogSimpleLiterals)
{
$this->writeLog('{'.\strlen($sLiteral).'} '.$sLiteral, \MailSo\Log\Enumerations\Type::INFO);
}
}
}
else

View file

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

View file

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

View file

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