Aleksander Machniak
2014-11-07 a7a778c157426f12f176648802a51c5e5397a81a
Fix some character sets detection (#1490135)
2 files modified
20 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_charset.php 19 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -52,6 +52,7 @@
- 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)
program/lib/Roundcube/rcube_charset.php
@@ -654,7 +654,6 @@
        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 @@
            case 'tr_TR':
                $prio = array('UTF-8', 'ISO-8859-9', 'WINDOWS-1254');
                break;
        }
            default:
        // 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;
                }
            }
        }
        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 @@
            $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