Permalink
Browse files

Add missing urlencoding to nested named parameters.

Fixes #2988
  • Loading branch information...
markstory committed Jul 3, 2012
1 parent 4b3a8ea commit 31033239bd06750358a8aea3542392209234278a
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/Cake/Routing/Route/CakeRoute.php
  2. +2 −2 lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php
@@ -497,9 +497,9 @@ protected function _writeUrl($params) {
$named = array();
foreach ($params['named'] as $key => $value) {
if (is_array($value)) {
$flat = Hash::flatten($value, '][');
$flat = Hash::flatten($value, '%5D%5B');
foreach ($flat as $namedKey => $namedValue) {
$named[] = $key . "[$namedKey]" . $separator . rawurlencode($namedValue);
$named[] = $key . "%5B{$namedKey}%5D" . $separator . rawurlencode($namedValue);
}
} else {
$named[] = $key . $separator . rawurlencode($value);
@@ -798,7 +798,7 @@ public function testMatchNamedParametersArray() {
)
);
$result = $route->match($url);
$expected = '/posts/index/filter[0]:one/filter[model]:value';
$expected = '/posts/index/filter%5B0%5D:one/filter%5Bmodel%5D:value';
$this->assertEquals($expected, $result);
$url = array(
@@ -813,7 +813,7 @@ public function testMatchNamedParametersArray() {
)
);
$result = $route->match($url);
$expected = '/posts/index/filter[0]:one/filter[model][0]:two/filter[model][order]:field';
$expected = '/posts/index/filter%5B0%5D:one/filter%5Bmodel%5D%5B0%5D:two/filter%5Bmodel%5D%5Border%5D:field';
$this->assertEquals($expected, $result);
}

0 comments on commit 3103323

Please sign in to comment.