From 8d6814e63f115d2887f84d4359993b9711c51728 Mon Sep 17 00:00:00 2001 From: "Melvin.Ross@gmail.com" Date: Fri, 24 Jan 2014 16:14:58 -0600 Subject: [PATCH 1/3] Remove rawurldecode from the _parseArgs function in CakeRoute since urldecode is already called on the URL string in CakeRoute::parse() when creating the $route array that is passed to _parseArgs. The result of the double urldecodes is parameters with meaningful '%' signs being stripped away on accident, and the web server reporting that the requested address doesn't exist. --- lib/Cake/Routing/Route/CakeRoute.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 88d094f66..e8247b38c 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -297,12 +297,12 @@ class CakeRoute { $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); - $key = rawurldecode($key); - $val = rawurldecode($val); + $key = key; + $val = $val; $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); if ($passIt) { - $pass[] = rawurldecode($param); + $pass[] = $param; } else { if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { $matches = array_reverse($matches); @@ -323,7 +323,7 @@ class CakeRoute { $named = array_merge_recursive($named, array($key => $val)); } } else { - $pass[] = rawurldecode($param); + $pass[] = $param; } } return array($pass, $named); From 83f37e48a9e6ee9885196f210e8bcaeab970a0b8 Mon Sep 17 00:00:00 2001 From: "Melvin.Ross@gmail.com" Date: Fri, 24 Jan 2014 16:33:59 -0600 Subject: [PATCH 2/3] Fix typo that removed '$' from '$key' --- lib/Cake/Routing/Route/CakeRoute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index e8247b38c..d7bdd0173 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -297,7 +297,7 @@ class CakeRoute { $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); - $key = key; + $key = $key; $val = $val; $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); From 7f496fad9431f7d01be7721b3c1ef352d932c506 Mon Sep 17 00:00:00 2001 From: "Melvin.Ross@gmail.com" Date: Fri, 24 Jan 2014 17:44:31 -0600 Subject: [PATCH 3/3] _Trailing_ and $this->keys also do not need to be urldecoded. Both _trailing_ and $this->keys gets set in _writeRoute, which also makes the regex that used to create the array $route. Any keys in $route that match [_trailing_] or any values in $this->keys are put there through the exection of preg_match. The URL is decoded before being passed to preg_match, which means the values inside of [_trailing_]etc. have already been decoded. --- lib/Cake/Routing/Route/CakeRoute.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index d7bdd0173..44fdb0eb7 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -235,7 +235,7 @@ class CakeRoute { foreach ($this->keys as $key) { if (isset($route[$key])) { - $route[$key] = rawurldecode($route[$key]); + $route[$key] = $route[$key]; } } @@ -247,7 +247,7 @@ class CakeRoute { } if (isset($route['_trailing_'])) { - $route['pass'][] = rawurldecode($route['_trailing_']); + $route['pass'][] = $route['_trailing_']; unset($route['_trailing_']); }