Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #18224 escapePatter for charset Shift_JIS
Submitted: 2011-01-27 16:59 UTC
From: sakai Assigned:
Status: Open Package: MDB2 (version 2.4.1)
PHP Version: 5.3.5 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2011-01-27 16:59 UTC] sakai (Kiyoshi Sakai)
Description: ------------ Almost always, MDB2's prepare/execute work with the charset (internal_encoding) of Shift_JIS. But it doesn't work properly with escapePattern. Simple str_replace on line 1656 of MDB2.php does NOT work with certain charset like SJIS. Below is a sample of '?' in UTF-8 Test script: --------------- http://example.com/?like=%95%5C <?php mb_internal_encoding('SJIS'); require_once('MDB2.php'); $mdb2 = MDB2::connect('pgsql:///testdb?charset=sjis'); $sth = $mdb2->prepare( 'SELECT * FROM tbl WHERE profile LIKE :profile', array('profile' => 'text') ); $res = $sth->execute(array('profile' => '%' . $mdb2->escapePattern($_GET['like']) . '%')); header('Content-Type: text/html; charset=Shift_JIS'); var_dump($mdb2->last_query); ?> Expected result: ---------------- string(70) "EXECUTE mdb2_statement_pgsql_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ('%?%')" Actual result: -------------- string(72) "EXECUTE mdb2_statement_pgsql_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ('%?\\%')"

Comments

 [2011-01-27 17:04 UTC] sakai (Kiyoshi Sakai)
'?' or '?' in the text is %E8%A1%A8 after urlencode in UTF-8, %95%5C after urlencode in SJIS