From e405586584276957d930f8d93071713412accacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 28 Dec 2015 11:49:32 +0100 Subject: [PATCH] Avoid conversion of MySQL error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The messages are properly encoded based on connection collation. This seems to be the case since introduction of the collations, but the code has stayed in phpMyAdmin since the times before it. Fixes #11788 Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/DatabaseInterface.class.php | 73 --------------------------- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4e8968ead9d..ddd39c3dc3bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ phpMyAdmin - ChangeLog - issue #11785 Set PHP's internal encoding to UTF-8 - issue #11786 Fixed Kanji encoding in some specific cases - issue #11787 Check whether iconv works before using it +- issue #11788 Avoid conversion of MySQL error messages 4.5.3.1 (2015-12-25) - issue #11774 Undefined offset 2 diff --git a/libraries/DatabaseInterface.class.php b/libraries/DatabaseInterface.class.php index 1c0005143bb7..e782b4a40553 100644 --- a/libraries/DatabaseInterface.class.php +++ b/libraries/DatabaseInterface.class.php @@ -279,75 +279,6 @@ public function tryMultiQuery($multi_query = '', $link = null) return $this->_extension->realMultiQuery($link, $multi_query); } - /** - * converts charset of a mysql message, usually coming from mysql_error(), - * into PMA charset, usually UTF-8 - * uses language to charset mapping from mysql/share/errmsg.txt - * and charset names to ISO charset from information_schema.CHARACTER_SETS - * - * @param string $message the message - * - * @return string $message - */ - public function convertMessage($message) - { - // latin always last! - // @todo some values are missing, - // see https://mariadb.com/kb/en/mariadb/server-locale/ - - $encodings = array( - 'ja' => 'EUC-JP', //'ujis', - 'ko' => 'EUC-KR', //'euckr', - 'ru' => 'KOI8-R', //'koi8r', - 'uk' => 'KOI8-U', //'koi8u', - 'sr' => 'CP1250', //'cp1250', - 'et' => 'ISO-8859-13', //'latin7', - 'sk' => 'ISO-8859-2', //'latin2', - 'cz' => 'ISO-8859-2', //'latin2', - 'hu' => 'ISO-8859-2', //'latin2', - 'pl' => 'ISO-8859-2', //'latin2', - 'ro' => 'ISO-8859-2', //'latin2', - 'es' => 'CP1252', //'latin1', - 'sv' => 'CP1252', //'latin1', - 'it' => 'CP1252', //'latin1', - 'no' => 'CP1252', //'latin1', - 'pt' => 'CP1252', //'latin1', - 'da' => 'CP1252', //'latin1', - 'nl' => 'CP1252', //'latin1', - 'en' => 'CP1252', //'latin1', - 'fr' => 'CP1252', //'latin1', - 'de' => 'CP1252', //'latin1', - ); - - $server_language = PMA_Util::cacheGet( - 'server_language', - function () { - return $GLOBALS['dbi']->fetchValue("SELECT @@lc_messages;"); - } - ); - - if ($server_language) { - $found = array(); - $match = preg_match( - '&([a-z][a-z])_&i', - $server_language, - $found - ); - if ($match) { - $server_language = $found[1]; - } - } - - if (! empty($server_language) && isset($encodings[$server_language])) { - $encoding = $encodings[$server_language]; - } else { - /* Fallback to CP1252 if we can not detect */ - $encoding = 'CP1252'; - } - - return PMA_convertString($encoding, 'utf-8', $message); - } - /** * returns array with table names for given db * @@ -2508,10 +2439,6 @@ public function getTriggers($db, $table = '', $delimiter = '//') */ public function formatError($error_number, $error_message) { - if (! empty($error_message)) { - $error_message = $this->convertMessage($error_message); - } - $error_message = htmlspecialchars($error_message); $error = '#' . ((string) $error_number);