mirror of
https://github.com/retailcrm/Fetch.git
synced 2024-11-25 20:36:01 +03:00
Catch exceptions from mb_convert_encoding and default to iconv
This commit is contained in:
parent
b96c24a3e9
commit
38dd385cb8
@ -10,6 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Fetch;
|
namespace Fetch;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This library is a wrapper around the Imap library functions included in php. This class represents a single email
|
* This library is a wrapper around the Imap library functions included in php. This class represents a single email
|
||||||
@ -463,10 +464,21 @@ 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) {
|
||||||
|
$mb_converted = false;
|
||||||
if (function_exists('mb_convert_encoding')) {
|
if (function_exists('mb_convert_encoding')) {
|
||||||
|
try {
|
||||||
$messageBody = mb_convert_encoding($messageBody, self::$charset, $parameters['charset']);
|
$messageBody = mb_convert_encoding($messageBody, self::$charset, $parameters['charset']);
|
||||||
} else {
|
$mb_converted = true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// @TODO Handle exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! $mb_converted) {
|
||||||
|
try {
|
||||||
$messageBody = iconv($parameters['charset'], self::$charset . self::$charsetFlag, $messageBody);
|
$messageBody = iconv($parameters['charset'], self::$charset . self::$charsetFlag, $messageBody);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// @TODO Handle exception
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user