From 80179f3428925b8a14263d3d3869024c58d55e27 Mon Sep 17 00:00:00 2001 From: Tom Sommer Date: Wed, 17 Feb 2016 13:01:18 +0100 Subject: [PATCH 1/2] Fix encoding bug in_array() is case-sensitive and $parameters['charset'] is lower-case while mb_list_encodings() is upper-case --- 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 e382678..2fa91ca 100755 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -523,7 +523,7 @@ protected function processStructure($structure, $partIdentifier = null) if (!empty($parameters['charset']) && $parameters['charset'] !== self::$charset) { $mb_converted = false; if (function_exists('mb_convert_encoding')) { - if (!in_array($parameters['charset'], mb_list_encodings())) { + if (!in_array(strtoupper($parameters['charset']), mb_list_encodings())) { if ($structure->encoding === 0) { $parameters['charset'] = 'US-ASCII'; } else { From 773feee57740a955402dd3e9d3b4a322807d4201 Mon Sep 17 00:00:00 2001 From: Tom Sommer Date: Tue, 10 Oct 2017 19:13:44 +0200 Subject: [PATCH 2/2] Force the output of mb_list_encodings() to be uppercase for comparison --- 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 2fa91ca..b679bac 100755 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -523,7 +523,7 @@ protected function processStructure($structure, $partIdentifier = null) if (!empty($parameters['charset']) && $parameters['charset'] !== self::$charset) { $mb_converted = false; if (function_exists('mb_convert_encoding')) { - if (!in_array(strtoupper($parameters['charset']), mb_list_encodings())) { + if (!in_array(strtoupper($parameters['charset']), array_map('strtoupper', mb_list_encodings()))) { if ($structure->encoding === 0) { $parameters['charset'] = 'US-ASCII'; } else {