8000 merged branch Tobion/fix-double-encoding (PR #6363) · loicfrering/symfony@d90e55c · GitHub
[go: up one dir, main page]

Skip to content

Commit d90e55c

Browse files
committed
merged branch Tobion/fix-double-encoding (PR symfony#6363)
This PR was merged into the 2.0 branch. Commits ------- 8b2c17f fix double-decoding in the routing system Discussion ---------- fix double-decoding in the routing system @fabpot @vicb This should fix it. You know what ;) Don't want to leak more information. And the good thing, it's no hack nor does it break BC.
2 parents 2f0b2a1 + 8b2c17f commit d90e55c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/RouterListener.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public function onKernelRequest(GetResponseEvent $event)
7070

7171
// add attributes based on the path info (routing)
7272
try {
73-
$parameters = $this->router->match($request->getPathInfo());
73+
// The path is returned in decoded form from the request, so we need to
74+
// encode it again as the router applies its own decoding. This prevents
75+
// double-decoding.
76+
$parameters = $this->router->match(urlencode($request->getPathInfo()));
7477

7578
if (null !== $this->logger) {
7679
$this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], $this->parametersToString($parameters)));

src/Symfony/Component/Security/Http/HttpUtils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function checkRequestPath(Request $request, $path)
107107
{
108108
if ('/' !== $path[0]) {
109109
try {
110-
$parameters = $this->router->match($request->getPathInfo());
110+
$parameters = $this->router->match(urlencode($request->getPathInfo()));
111111

112112
return $path === $parameters['_route'];
113113
} catch (MethodNotAllowedException $e) {
@@ -129,7 +129,7 @@ private function resetLocale(Request $request)
129129
}
130130

131131
try {
132-
$parameters = $this->router->match($request->getPathInfo());
132+
$parameters = $this->router->match(urlencode($request->getPathInfo()));
133133

134134
if (isset($parameters['_locale'])) {
135135
$context->setParameter('_locale', $parameters['_locale']);

0 commit comments

Comments
 (0)
0