From 57bd1ea5f94b779ce26d00e5a3685bf066a5586b Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 30 Jan 2012 00:25:48 +0200 Subject: [PATCH 1/2] added test for check nested url --- .../Test/Case/Routing/Route/CakeRouteTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index d27128dbb..ace61e181 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -403,6 +403,26 @@ class CakeRouteTest extends CakeTestCase { $this->assertEquals('something else', $result['pass'][0]); } +/** + * Ensure that keys at named parameters are urldecoded + * + * @return void + */ + public function testParseNamedKeyUrlDecode() { + Router::connectNamed(true); + $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + + // checking /post/index/user[0]:a/user[1]:b + $result = $route->parse('/posts/index/user%5B0%5D:a/user%5B1%5D:b'); + $this->assertArrayHasKey('user', $result['named']); + $this->assertEquals(array('a', 'b'), $result['named']['user']); + + // checking /post/index/user[]:a/user[]:b + $result = $route->parse('/posts/index/user%5B%5D:a/user%5B%5D:b'); + $this->assertArrayHasKey('user', $result['named']); + $this->assertEquals(array('a', 'b'), $result['named']['user']); + } + /** * test that named params with null/false are excluded * From 57eec6e6fc0a9d78274231f3d22ceb7896687a8f Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 30 Jan 2012 00:26:56 +0200 Subject: [PATCH 2/2] added decoding of keys for named parameters --- lib/Cake/Routing/Route/CakeRoute.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 7eab5bfd3..2452d273b 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -275,6 +275,7 @@ class CakeRoute { $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); + $key = rawurldecode($key); $val = rawurldecode($val); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context));