From d3c2fbf2d6d65f3d990d6b74eb2fc04ccea810b1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 29 Aug 2012 09:22:07 +0200 Subject: Fix decoding of HTML messages with UTF-16 charset specified (#1488654) --- program/include/rcube_charset.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'program') diff --git a/program/include/rcube_charset.php b/program/include/rcube_charset.php index 7e8fe4997..fc1685d28 100644 --- a/program/include/rcube_charset.php +++ b/program/include/rcube_charset.php @@ -185,6 +185,12 @@ class rcube_charset $to = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse($to); $from = self::parse($from); + // It is a common case when UTF-16 charset is used with US-ASCII content (#1488654) + // In that case we can just skip the conversion (use UTF-8) + if ($from == 'UTF-16' && !preg_match('/[^\x00-\x7F]/', $str)) { + $from = 'UTF-8'; + } + if ($from == $to || empty($str) || empty($from)) { return $str; } -- cgit v1.2.3