Add missing urlencoding to nested named parameters.

Fixes #2988
This commit is contained in:
mark_story 2012-07-02 23:34:37 -04:00
parent 4b3a8ea348
commit 31033239bd
2 changed files with 4 additions and 4 deletions

View file

@ -497,9 +497,9 @@ class CakeRoute {
$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);

View file

@ -798,7 +798,7 @@ class CakeRouteTest extends CakeTestCase {
)
);
$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 @@ class CakeRouteTest extends CakeTestCase {
)
);
$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);
}