summaryrefslogtreecommitdiff
path: root/program/include/rcube_charset.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-08-29 09:22:07 +0200
committerAleksander Machniak <alec@alec.pl>2012-08-29 09:22:07 +0200
commit764641d4a38e0a9856cced092ac7c294a2956dcf (patch)
tree9e318e96c8911b971e0e8e3d11f111ebffe1ff9e /program/include/rcube_charset.php
parent0062becea70392c4a21f3ef8367f65e93d2c1f67 (diff)
Fix decoding of HTML messages with UTF-16 charset specified (#1488654)
Diffstat (limited to 'program/include/rcube_charset.php')
-rw-r--r--program/include/rcube_charset.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/program/include/rcube_charset.php b/program/include/rcube_charset.php
index 380d14978..1740a6096 100644
--- a/program/include/rcube_charset.php
+++ b/program/include/rcube_charset.php
@@ -181,6 +181,12 @@ class rcube_charset
$to = empty($to) ? strtoupper(RCMAIL_CHARSET) : self::parse_charset($to);
$from = self::parse_charset($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;
}