Skip to content

Commit

Permalink
Add missing urlencoding to nested named parameters.
Browse files Browse the repository at this point in the history
Fixes #2988
  • Loading branch information
markstory committed Jul 3, 2012
1 parent 4b3a8ea commit 3103323
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Routing/Route/CakeRoute.php
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php
Expand Up @@ -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(
Expand All @@ -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);
}

Expand Down

0 comments on commit 3103323

Please sign in to comment.