Fix some character sets detection (#1490135)

pull/247/head
Aleksander Machniak 10 years ago
parent 9ba5b878d1
commit a7a778c157

@ -52,6 +52,7 @@ CHANGELOG Roundcube Webmail
- Don't remove links when html signature is converted to text (#1489621)
- Fix page title when using search filter (#1490023)
- Fix mbox files import
- Fix some character sets detection (#1490135)
- Fix so attachment charset is set in headers of forward/draft message (#1490109)
- Fix bug where wrong charset could be used for text attachment preview page (#1490106)
- Fix setting flags on servers with no PERMANENTFLAGS response (#1490087)

@ -654,7 +654,6 @@ class rcube_charset
if ($string[0] == "\0" && $string[1] != "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-16BE';
if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE';
if (function_exists('mb_detect_encoding')) {
if (empty($language)) {
$rcube = rcube::get_instance();
$language = $rcube->get_user_language();
@ -682,8 +681,20 @@ class rcube_charset
case 'tr_TR':
$prio = array('UTF-8', 'ISO-8859-9', 'WINDOWS-1254');
break;
}
// mb_detect_encoding() is not reliable for some charsets (#1490135)
// use mb_check_encoding() to make charset priority lists really working
if ($prio && function_exists('mb_check_encoding')) {
foreach ($prio as $encoding) {
if (mb_check_encoding($string, $encoding)) {
return $encoding;
}
}
}
default:
if (function_exists('mb_detect_encoding')) {
if (!$prio) {
$prio = array('UTF-8', 'SJIS', 'GB2312',
'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
@ -695,7 +706,9 @@ class rcube_charset
$encodings = array_unique(array_merge($prio, mb_list_encodings()));
return mb_detect_encoding($string, $encodings);
if ($encoding = mb_detect_encoding($string, $encodings)) {
return $encoding;
}
}
// No match, check for UTF-8

Loading…
Cancel
Save