Skip to content

Commit

Permalink
[Security] fixed redirection URLs when using {_locale} in the pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jul 11, 2011
1 parent 9301ad0 commit ea7a0eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Symfony/Component/Security/Http/HttpUtils.php
Expand Up @@ -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);
}

Expand Down

0 comments on commit ea7a0eb

Please sign in to comment.