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

Bug #4897 incorrect links when include Multibyte String
Submitted: 2005-07-23 08:16 UTC
From: kenchou77 at gmail dot com Assigned: quipo
Status: Closed Package: Pager
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 18 - 8 = ?

 
 [2005-07-23 08:16 UTC] kenchou77 at gmail dot com
Description: ------------ Pager build incorrect query string on chinese chars. Maybe all htmlentities should replace with htmlspecialchars.

Comments

 [2005-08-01 17:44 UTC] astor at 21cn dot com
I think this bug is caused by the usage of htmlentities instead of urlencode, since 2.3.0 works well.
 [2005-08-04 17:06 UTC] quipo
hi, can you send me a reproducing script? Or, better yet, a testcase [1]? I don't have any test with multibyte strings yet, and I'd love to have some. Thanks for your help! [1] http://cvs.php.net/pear/Pager/tests/
 [2005-08-05 08:23 UTC] kenchou77 at gmail dot com
The test Script based on docs/Pager/example/example.php: <?php require_once 'Pager/Pager.php'; //create dummy array of data $myData = array(); for ($i=0; $i<200; $i++) { $myData[] = $i; } //set a string $test_string = '测试'; $params = array( 'itemData' => $myData, 'perPage' => 10, 'delta' => 8, 'append' => true, 'clearIfVoid' => false, 'urlVar' => 'entrant', 'useSessions' => true, 'closeSession' => true, 'mode' => 'Jumping', 'extraVars' => array('test' => $test_string) ); $pager = & Pager::factory($params); $page_data = $pager->getPageData(); $links = $pager->getLinks(); $selectBox = $pager->getPerPageSelectBox(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Pager Test</title> </head> <body> <?php //compare string if (isset($_REQUEST['test'])) { $request_test = $_REQUEST['test']; var_dump($request_test, $test_string, ($request_test == $test_string)); } ?> <table border="1" width="500" summary="example 1"> <tr> <td colspan="3" align="center"> <?php echo $links['all']; ?> </td> </tr> <tr> <td colspan="3"> <pre><?php print_r($page_data); ?></pre> </td> </tr> </table> <h4>Results from methods:</h4> <pre> getCurrentPageID()...: <?php var_dump($pager->getCurrentPageID()); ?> getNextPageID()......: <?php var_dump($pager->getNextPageID()); ?> getPreviousPageID()..: <?php var_dump($pager->getPreviousPageID()); ?> numItems()...........: <?php var_dump($pager->numItems()); ?> numPages()...........: <?php var_dump($pager->numPages()); ?> isFirstPage()........: <?php var_dump($pager->isFirstPage()); ?> isLastPage().........: <?php var_dump($pager->isLastPage()); ?> isLastPageComplete().: <?php var_dump($pager->isLastPageComplete()); ?> $pager->range........: <?php var_dump($pager->range); ?> </pre> <hr /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> Select how many items per page should be shown:<br /> <?php echo $selectBox; ?>   <input type="submit" value="submit" /> </form> <hr /> </body> </html> ------------- Expected result: string(8) "测试" string(4) "测试" bool(true) ----------- Actual result: string(8) "虏芒脢脭" string(4) "测试" bool(false)
 [2005-09-27 04:29 UTC] daniel at konczyk dot net
You need to encode the var before you use htmlentities, otherwise, htmlentities encodes the multibyte char wrong. I've made a change in _http_build_query_wrapper function: 1175 array_push($tmp, key.'='.urlencode($val)); And that fixes the problem. Well, as far as I tested.. I'm using 2.3.0
 [2005-09-27 07:53 UTC] quipo
sorry, I got swamped with work. Can you try the latest CVS version of all the Pager files? If it works correctly, I'll roll out a new release.
 [2005-09-28 08:05 UTC] kenchou77 at gmail dot com
OK, the latest CVS version works correctly :)
 [2005-09-28 18:17 UTC] daniel at konczyk dot net
It works for me too (latest cvs) Can you please make a new release then?
 [2005-09-28 19:20 UTC] quipo
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Pager -- > Can you please make a new release then? done! Thank you guys for your precious feedback!