From ea7a0eb19c487e882693659d472aca61bed4a9ed Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 11 Jul 2011 08:09:36 +0200 Subject: [PATCH] [Security] fixed redirection URLs when using {_locale} in the pattern --- src/Symfony/Component/Security/Http/HttpUtils.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index 9ac604e4fdea..51168cc1e37d 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -48,6 +48,19 @@ public function createRedirectResponse(Request $request, $path, $status = 302) if (0 === strpos($path, '/')) { $path = $request->getUriForPath($path); } elseif (0 !== strpos($path, 'http')) { + // hack (don't have a better solution for now) + $context = $this->router->getContext(); + try { + $parameters = $this->router->match($request->getPathInfo()); + } catch (\Exception $e) { + } + + if (isset($parameters['_locale'])) { + $context->setParameter('_locale', $parameters['_locale']); + } elseif ($session = $request->getSession()) { + $context->setParameter('_locale', $session->getLocale()); + } + $path = $this->generateUrl($path, true); }