From 8b2c17f80377582287a78e0b521497e039dd6b0d Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 14 Dec 2012 23:08:21 +0100 Subject: [PATCH] fix double-decoding in the routing system --- .../Bundle/FrameworkBundle/EventListener/RouterListener.php | 5 ++++- src/Symfony/Component/Security/Http/HttpUtils.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php index 5cd959e73c9b..1c8ea585cacc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php @@ -70,7 +70,10 @@ public function onKernelRequest(GetResponseEvent $event) // add attributes based on the path info (routing) try { - $parameters = $this->router->match($request->getPathInfo()); + // The path is returned in decoded form from the request, so we need to + // encode it again as the router applies its own decoding. This prevents + // double-decoding. + $parameters = $this->router->match(urlencode($request->getPathInfo())); if (null !== $this->logger) { $this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters))); diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index cac130ed9712..78bfb85475d1 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -107,7 +107,7 @@ public function checkRequestPath(Request $request, $path) { if ('/' !== $path[0]) { try { - $parameters = $this->router->match($request->getPathInfo()); + $parameters = $this->router->match(urlencode($request->getPathInfo())); return $path === $parameters['_route']; } catch (MethodNotAllowedException $e) { @@ -129,7 +129,7 @@ private function resetLocale(Request $request) } try { - $parameters = $this->router->match($request->getPathInfo()); + $parameters = $this->router->match(urlencode($request->getPathInfo())); if (isset($parameters['_locale'])) { $context->setParameter('_locale', $parameters['_locale']);