Skip to content

Commit

Permalink
Fix issue with dots in request URLs.
Browse files Browse the repository at this point in the history
Dots in request url's often resulted in an additional get parameter
being added.

Fixes #2303
  • Loading branch information
markstory committed Nov 27, 2011
1 parent 6f28522 commit 390db7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -184,7 +184,7 @@ protected function _processGet() {
$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);
Expand Down
15 changes: 15 additions & 0 deletions lib/Cake/Test/Case/Network/CakeRequestTest.php
Expand Up @@ -1056,6 +1056,21 @@ public function testBaseUrlNoRewriteWebrootIndex() {
$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
*
Expand Down

0 comments on commit 390db7b

Please sign in to comment.