Permalink
Browse files

Add missing rawurlencode()

When routes fail to match because of unknown named parameters,
values that needed urlencoding were missing it.

Fixes #2572
  • Loading branch information...
1 parent afecb71 commit 76711c9f7129e09a6da72b930d6d364fbfd14e04 @markstory markstory committed Feb 14, 2012
Showing with 6 additions and 4 deletions.
  1. +3 −3 lib/Cake/Routing/Router.php
  2. +3 −1 lib/Cake/Test/Case/Routing/RouterTest.php
@@ -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);
}
}
}
@@ -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);
}
@@ -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'));

0 comments on commit 76711c9

Please sign in to comment.