Skip to content

Commit

Permalink
Add missing rawurlencode()
Browse files Browse the repository at this point in the history
When routes fail to match because of unknown named parameters,
values that needed urlencoding were missing it.

Fixes #2572
  • Loading branch information
markstory committed Feb 14, 2012
1 parent afecb71 commit 76711c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Routing/Router.php
Expand Up @@ -917,18 +917,18 @@ protected static function _handleNoRoute($url) {
$output = implode('/', $urlOut);

if (!empty($args)) {
$output .= '/' . implode('/', $args);
$output .= '/' . implode('/', array_map('rawurlencode', $args));
}

if (!empty($named)) {
foreach ($named as $name => $value) {
if (is_array($value)) {
$flattend = Set::flatten($value, '][');
foreach ($flattend as $namedKey => $namedValue) {
$output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . $namedValue;
$output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . rawurlencode($namedValue);
}
} else {
$output .= '/' . $name . self::$_namedConfig['separator'] . $value;
$output .= '/' . $name . self::$_namedConfig['separator'] . rawurlencode($value);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -503,7 +503,7 @@ public function testArrayNamedParameters() {
'keyed' => 'is an array',
'test'
)));
$expected = '/tests/index/namedParam[keyed]:is an array/namedParam[0]:test';
$expected = '/tests/index/namedParam[keyed]:is%20an%20array/namedParam[0]:test';
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -1705,6 +1705,8 @@ public function testPrefixOverride() {
*/
public function testPrefixFalseIgnored() {
Configure::write('Routing.prefixes', array('admin'));
Router::reload();

Router::connect('/cache_css/*', array('admin' => false, 'controller' => 'asset_compress', 'action' => 'get'));

$url = Router::url(array('controller' => 'asset_compress', 'action' => 'get', 'test'));
Expand Down

0 comments on commit 76711c9

Please sign in to comment.