mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge pull request #2694 from bar/patch-3
Correctly remove routing url from query string.
This commit is contained in:
commit
ddf046a246
2 changed files with 47 additions and 3 deletions
|
@ -207,7 +207,7 @@ class CakeRequest implements ArrayAccess {
|
|||
$query = $_GET;
|
||||
}
|
||||
|
||||
unset($query['/' . str_replace('.', '_', urldecode($this->url))]);
|
||||
unset($query[$this->base . '/' . str_replace('.', '_', urldecode($this->url))]);
|
||||
if (strpos($this->url, '?') !== false) {
|
||||
list(, $querystr) = explode('?', $this->url);
|
||||
parse_str($querystr, $queryArgs);
|
||||
|
|
|
@ -1484,10 +1484,18 @@ class CakeRequestTest extends CakeTestCase {
|
|||
public function testGetParamsWithDot() {
|
||||
$_GET = array();
|
||||
$_GET['/posts/index/add_add'] = '';
|
||||
$_SERVER['PHP_SELF'] = '/app/webroot/index.php';
|
||||
$_SERVER['REQUEST_URI'] = '/posts/index/add.add';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('', $request->base);
|
||||
$this->assertEquals(array(), $request->query);
|
||||
|
||||
$_GET = array();
|
||||
$_GET['/cake_dev/posts/index/add_add'] = '';
|
||||
$_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php';
|
||||
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add';
|
||||
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('/cake_dev', $request->base);
|
||||
$this->assertEquals(array(), $request->query);
|
||||
}
|
||||
|
||||
|
@ -1499,10 +1507,18 @@ class CakeRequestTest extends CakeTestCase {
|
|||
public function testGetParamWithUrlencodedElement() {
|
||||
$_GET = array();
|
||||
$_GET['/posts/add/∂∂'] = '';
|
||||
$_SERVER['PHP_SELF'] = '/app/webroot/index.php';
|
||||
$_SERVER['REQUEST_URI'] = '/posts/add/%E2%88%82%E2%88%82';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('', $request->base);
|
||||
$this->assertEquals(array(), $request->query);
|
||||
|
||||
$_GET = array();
|
||||
$_GET['/cake_dev/posts/add/∂∂'] = '';
|
||||
$_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php';
|
||||
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/add/%E2%88%82%E2%88%82';
|
||||
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('/cake_dev', $request->base);
|
||||
$this->assertEquals(array(), $request->query);
|
||||
}
|
||||
|
||||
|
@ -1877,6 +1893,34 @@ class CakeRequestTest extends CakeTestCase {
|
|||
'urlParams' => array()
|
||||
),
|
||||
),
|
||||
array(
|
||||
'Nginx - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO, base parameter set',
|
||||
array(
|
||||
'App' => array(
|
||||
'base' => false,
|
||||
'baseUrl' => false,
|
||||
'dir' => 'app',
|
||||
'webroot' => 'webroot'
|
||||
),
|
||||
'GET' => array('/site/posts/add' => ''),
|
||||
'SERVER' => array(
|
||||
'SERVER_NAME' => 'localhost',
|
||||
'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
|
||||
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
|
||||
'SCRIPT_NAME' => '/site/app/webroot/index.php',
|
||||
'QUERY_STRING' => '/site/posts/add&',
|
||||
'PHP_SELF' => '/site/app/webroot/index.php',
|
||||
'PATH_INFO' => null,
|
||||
'REQUEST_URI' => '/site/posts/add',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'url' => 'posts/add',
|
||||
'base' => '/site',
|
||||
'webroot' => '/site/',
|
||||
'urlParams' => array()
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue