From 390db7beba59c0a070e1b0764768cad4c5059100 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 26 Nov 2011 21:24:53 -0500 Subject: [PATCH] Fix issue with dots in request URLs. Dots in request url's often resulted in an additional get parameter being added. Fixes #2303 --- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Test/Case/Network/CakeRequestTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 7da41879a75..5816430a93a 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -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); diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 95f84816e9b..95bf2177fef 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -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 *