Check to see if message is already encoded in utf8

Adding requirement to if statement to check if message matches UTF-8 encoding via regex. This will prevent encoding errors when converting UTF-8 to UTF-8.
This commit is contained in:
Alex Kavon 2014-06-12 09:55:34 -06:00
parent 8e742ef80e
commit 04b5a5ed33

View File

@ -437,7 +437,7 @@ class Message
$messageBody = self::decode($messageBody, $structure->encoding);
if (!empty($parameters['charset']) && $parameters['charset'] !== self::$charset)
if (!empty($parameters['charset']) && !preg_match('/utf-?8/i', $parameters['charset']) && $parameters['charset'] !== self::$charset)
$messageBody = iconv($parameters['charset'], self::$charset, $messageBody);
if (strtolower($structure->subtype) === 'plain' || ($structure->type == 1 && strtolower($structure->subtype) !== 'alternative')) {