From 04b5a5ed33c62cbf38e2a77a03d19360d51206dc Mon Sep 17 00:00:00 2001 From: Alex Kavon Date: Thu, 12 Jun 2014 09:55:34 -0600 Subject: [PATCH] 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. --- src/Fetch/Message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index 06ffc7c..537b0ea 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -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')) {