mirror of
https://github.com/retailcrm/Fetch.git
synced 2025-02-06 10:39:21 +03:00
Merge pull request #66 from alexkavon/patch-2
Check to see if message is already encoded in utf8
This commit is contained in:
commit
ca5a988e82
@ -167,7 +167,15 @@ class Message
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $charset = 'UTF-8//TRANSLIT';
|
public static $charset = 'UTF-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This value defines the flag set for encoding if the mb_convert_encoding
|
||||||
|
* function can't be found, and in this case iconv encoding will be used.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $charsetFlag = '//TRANSLIT';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor takes in the uid for the message and the Imap class representing the mailbox the
|
* This constructor takes in the uid for the message and the Imap class representing the mailbox the
|
||||||
@ -352,7 +360,6 @@ class Message
|
|||||||
if (!in_array($type, $addressTypes) || !isset($this->$type) || count($this->$type) < 1)
|
if (!in_array($type, $addressTypes) || !isset($this->$type) || count($this->$type) < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (!$asString) {
|
if (!$asString) {
|
||||||
if ($type == 'from')
|
if ($type == 'from')
|
||||||
return $this->from[0];
|
return $this->from[0];
|
||||||
@ -437,8 +444,13 @@ class Message
|
|||||||
|
|
||||||
$messageBody = self::decode($messageBody, $structure->encoding);
|
$messageBody = self::decode($messageBody, $structure->encoding);
|
||||||
|
|
||||||
if (!empty($parameters['charset']) && $parameters['charset'] !== self::$charset)
|
if (!empty($parameters['charset']) && $parameters['charset'] !== self::$charset) {
|
||||||
$messageBody = iconv($parameters['charset'], self::$charset, $messageBody);
|
if (function_exists('mb_convert_encoding')) {
|
||||||
|
$messageBody = mb_convert_encoding($messageBody, self::$charset, $parameters['charset']);
|
||||||
|
} else {
|
||||||
|
$messageBody = iconv($parameters['charset'], self::$charset . self::$charsetFlag, $messageBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (strtolower($structure->subtype) === 'plain' || ($structure->type == 1 && strtolower($structure->subtype) !== 'alternative')) {
|
if (strtolower($structure->subtype) === 'plain' || ($structure->type == 1 && strtolower($structure->subtype) !== 'alternative')) {
|
||||||
if (isset($this->plaintextMessage)) {
|
if (isset($this->plaintextMessage)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user