mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix issue with url parsing and /?
PHP's parse_url fails to parse url's containing `/?`. It returns false instead of something useful. Fixes #2354
This commit is contained in:
parent
bbd6e22e26
commit
b7f6645cec
2 changed files with 18 additions and 2 deletions
|
@ -222,7 +222,7 @@ class CakeRequest implements ArrayAccess {
|
|||
$uri = substr($uri, strlen($base));
|
||||
}
|
||||
if (strpos($uri, '?') !== false) {
|
||||
$uri = parse_url($uri, PHP_URL_PATH);
|
||||
list($uri) = explode('?', $uri, 2);
|
||||
}
|
||||
if (empty($uri) || $uri == '/' || $uri == '//') {
|
||||
return '/';
|
||||
|
|
|
@ -104,11 +104,26 @@ class CakeRequestTest extends CakeTestCase {
|
|||
$_GET = array();
|
||||
$request = new CakeRequest('some/path?one=something&two=else');
|
||||
$expected = array('one' => 'something', 'two' => 'else');
|
||||
$this->assertEquals($request->query, $expected);
|
||||
$this->assertEquals($expected, $request->query);
|
||||
$this->assertEquals('some/path?one=something&two=else', $request->url);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that named arguments + querystrings are handled correctly.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryStringAndNamedParams() {
|
||||
$_SERVER['REQUEST_URI'] = '/tasks/index/page:1?ts=123456';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('tasks/index/page:1', $request->url);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = '/tasks/index/page:1/?ts=123456';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('tasks/index/page:1/', $request->url);
|
||||
}
|
||||
|
||||
/**
|
||||
* test addParams() method
|
||||
*
|
||||
|
@ -1623,6 +1638,7 @@ XML;
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* loadEnvironment method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue