Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

url encode nested named parameters in unmatched routes

reference: #2988
and 3103323
  • Loading branch information...
commit fa6defea3764de1fe98f5178737cd1829757758f 1 parent 52f2060
@AD7six AD7six authored
View
4 lib/Cake/Routing/Router.php
@@ -945,9 +945,9 @@ protected static function _handleNoRoute($url) {
if (!empty($named)) {
foreach ($named as $name => $value) {
if (is_array($value)) {
- $flattend = Hash::flatten($value, '][');
+ $flattend = Hash::flatten($value, '%5D%5B');
foreach ($flattend as $namedKey => $namedValue) {
- $output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . rawurlencode($namedValue);
+ $output .= '/' . $name . "%5B{$namedKey}%5D" . self::$_namedConfig['separator'] . rawurlencode($namedValue);
}
} else {
$output .= '/' . $name . self::$_namedConfig['separator'] . rawurlencode($value);
View
10 lib/Cake/Test/Case/Routing/RouterTest.php
@@ -484,7 +484,7 @@ public function testArrayNamedParameters() {
$result = Router::url(array('controller' => 'tests', 'pages' => array(
1, 2, 3
)));
- $expected = '/tests/index/pages[0]:1/pages[1]:2/pages[2]:3';
+ $expected = '/tests/index/pages%5B0%5D:1/pages%5B1%5D:2/pages%5B2%5D:3';
$this->assertEquals($expected, $result);
$result = Router::url(array('controller' => 'tests',
@@ -496,7 +496,7 @@ public function testArrayNamedParameters() {
'three'
)
));
- $expected = '/tests/index/pages[param1][0]:one/pages[param1][1]:two/pages[0]:three';
+ $expected = '/tests/index/pages%5Bparam1%5D%5B0%5D:one/pages%5Bparam1%5D%5B1%5D:two/pages%5B0%5D:three';
$this->assertEquals($expected, $result);
$result = Router::url(array('controller' => 'tests',
@@ -508,7 +508,7 @@ public function testArrayNamedParameters() {
'three'
)
));
- $expected = '/tests/index/pages[param1][one]:1/pages[param1][two]:2/pages[0]:three';
+ $expected = '/tests/index/pages%5Bparam1%5D%5Bone%5D:1/pages%5Bparam1%5D%5Btwo%5D:2/pages%5B0%5D:three';
$this->assertEquals($expected, $result);
$result = Router::url(array('controller' => 'tests',
@@ -520,14 +520,14 @@ public function testArrayNamedParameters() {
'cool'
)
));
- $expected = '/tests/index/super[nested][array]:awesome/super[nested][something]:else/super[0]:cool';
+ $expected = '/tests/index/super%5Bnested%5D%5Barray%5D:awesome/super%5Bnested%5D%5Bsomething%5D:else/super%5B0%5D:cool';
$this->assertEquals($expected, $result);
$result = Router::url(array('controller' => 'tests', 'namedParam' => array(
'keyed' => 'is an array',
'test'
)));
- $expected = '/tests/index/namedParam[keyed]:is%20an%20array/namedParam[0]:test';
+ $expected = '/tests/index/namedParam%5Bkeyed%5D:is%20an%20array/namedParam%5B0%5D:test';
$this->assertEquals($expected, $result);
}
Please sign in to comment.
Something went wrong with that request. Please try again.