Page MenuHomePhabricator

Wrong Encoding in mysql_client_encoding function within euckr mysql collation.
Closed, DeclinedPublic

Description

Author: kimbeast

Description:
There is problem to encode using mysql_client_encoding() function in Database.php
So save wrong Article/Text everything that written in Korean.

PHP Version : 5.1.2
mysql version : mysql Ver 14.7 Distrib 4.1.13, for pc-linux-gnu (i686) using
readline 4.3

mysql variables :

character_set_clienteuckr
character_set_connectioneuckr
character_set_databaseeuckr
character_set_resultseuckr
character_set_servereuckr
character_set_systemutf8
character_sets_dir/usr/local/mysql4113/share/mysql/charsets/
collation_connectioneuckr_korean_ci
collation_databaseeuckr_korean_ci
collation_servereuckr_korean_ci

Like this.

before mysql_client_encoding();
ㅋㅋㅋㅋㅋㅋㅋㅋ
after mysql_client_encoding();
ㅋ\ㅋㅋ\ㅋㅋ\ㅋㅋ\ㅋ

before mysql_client_encoding();
한글
after mysql_client_encoding();

\한글

as this result.
can't find article and save wrong text in database.

But with mysql's collation/character_set_encoding is latin1, this is ok work well.

i fixed this problem

First install with option (for mysql4 or mysql5 using UTF8)
And then hange strencode function in Database.php, like this.

/**
 * Wrapper for addslashes()
 * @param string $s String to be slashed.
 * @return string slashed string.
 */
function strencode( $s ) {
        //return mysql_real_escape_string( $s, $this->mConn );
        return addslashes( $s );
}

Version: 1.7.x
Severity: major
OS: Linux
Platform: PC

Details

Reference
bz7112

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 9:22 PM
bzimport set Reference to bz7112.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

The "workaround" described above is NOT safe for escaping all data prior to
insertion in the database and should not be replicated on other installations
without a good reason.

Either you should use the default latin1 encoding, or you should use the UTF-8 schema with
UTF-8 client mode enabled on MySQL 4.1 or higher. Nothing else is supported nor will it
become supported.