PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » Pager » Bug #3254

problem when URL variable contains a space

Details

Submitted2005-01-20 21:06 UTC
Fromigantius dot reilly at free dot fr
Assignedquipo
StatusClosed
PackagePager
PHP VersionIrrelevant
OSirrelevant
Roadmaps(Not assigned)

Comments

[2005-01-20 21:06 UTC] igantius dot reilly at free dot fr

Description:
------------
when query string contains a + (representing a space in the variable value), the "+" is URL-encoded a second time.

Reproduce code:
---------------
Consider the following page, say "/example.php"

<?php
require_once 'Pager/Pager.php';

//create dummy array of data
$myData = array();
for ($i=0; $i<200; $i++) {
$myData[] = $i;
}
$params = array(
'itemData' => $myData,
'perPage' => 10,
'delta' => 8, // for 'Jumping'-style a lower number is better
'append' => true,
//'separator' => ' | ',
'clearIfVoid' => false,
'urlVar' => 'page',
'useSessions' => true,
'closeSession' => true,
//'mode' => 'Sliding', //try switching modes
'mode' => 'Jumping',

);
$pager = & Pager::factory( $params );
$page_data = $pager->getPageData();
$links = $pager->getLinks();

echo $links['all'];
?>

Expected result:
----------------
Calling the following:
/example.php?param=a+b

Should give the following pager links:

<a href="/pager.php?param=a+b&page=1" title="previous page">

Actual result:
--------------
But gives instead:

<a href="/pager.php?param=a%252Bb&page=1" title="previous page">

+++++++++++++++++++
Proposed fix:

Pager/Common.php, line 658
instead of:
$querystring[] = rawurlencode($name) . '=' . rawurlencode($value);
now:
$querystring[] = urlencode($name) . '=' . urlencode( str_replace( "+", " ", $value ) );