From 76711c9f7129e09a6da72b930d6d364fbfd14e04 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Feb 2012 21:16:57 -0500 Subject: [PATCH] Add missing rawurlencode() When routes fail to match because of unknown named parameters, values that needed urlencoding were missing it. Fixes #2572 --- lib/Cake/Routing/Router.php | 6 +++--- lib/Cake/Test/Case/Routing/RouterTest.php | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index f382ad26a..1fb7299c9 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -917,7 +917,7 @@ class Router { $output = implode('/', $urlOut); if (!empty($args)) { - $output .= '/' . implode('/', $args); + $output .= '/' . implode('/', array_map('rawurlencode', $args)); } if (!empty($named)) { @@ -925,10 +925,10 @@ class Router { 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); } } } diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index a5946bb7a..272fb6de6 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -503,7 +503,7 @@ class RouterTest extends CakeTestCase { '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 @@ class RouterTest extends CakeTestCase { */ 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'));