Skip to content

Commit 9c7a140

Browse files
committed
[Security] fixed default target path when referer contains a query string
1 parent b1f1ae2 commit 9c7a140

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ protected function determineTargetUrl(Request $request)
118118
return $targetUrl;
119119
}
120120

121-
if ($this->options['use_referer'] && ($targetUrl = $request->headers->get('Referer')) && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
122-
return $targetUrl;
121+
if ($this->options['use_referer']) {
122+
$targetUrl = $request->headers->get('Referer');
123+
if (false !== $pos = strpos($targetUrl, '?')) {
124+
$targetUrl = substr($targetUrl, 0, $pos);
125+
}
126+
if ($targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
127+
return $targetUrl;
128+
}
123129
}
124130

125131
return $this->options['default_target_path'];

0 commit comments

Comments
 (0)