Fix issue with dots in request URLs.

Dots in request url's often resulted in an additional get parameter
being added.

Fixes #2303
This commit is contained in:
mark_story 2011-11-26 21:24:53 -05:00
parent 6f285224ae
commit 390db7beba
2 changed files with 16 additions and 1 deletions

View file

@ -184,7 +184,7 @@ class CakeRequest implements ArrayAccess {
$query = $_GET;
}
unset($query['/' . $this->url]);
unset($query['/' . str_replace('.', '_', $this->url)]);
if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs);

View file

@ -1056,6 +1056,21 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('/', $request->webroot);
}
/**
* Test that a request with a . in the main GET parameter is filtered out.
* PHP changes GET parameter keys containing dots to _.
*
* @return void
*/
public function testGetParamsWithDot() {
$_GET['/posts/index/add_add'] = '';
$_SERVER['SCRIPT_NAME'] = '/cake_dev/app/webroot/index.php';
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add';
$request = new CakeRequest();
$this->assertEquals(array(), $request->query);
}
/**
* generator for environment configurations
*