Skip to content

Commit

Permalink
[Security] Fix exception when use_referer option is true and referer …
Browse files Browse the repository at this point in the history
…is not set or empty
  • Loading branch information
linniksa authored and fabpot committed Sep 7, 2017
1 parent d74144f commit a29e069
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -118,12 +118,11 @@ protected function determineTargetUrl(Request $request)
return $targetUrl;
}

if ($this->options['use_referer']) {
$targetUrl = $request->headers->get('Referer');
if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) {
if (false !== $pos = strpos($targetUrl, '?')) {
$targetUrl = substr($targetUrl, 0, $pos);
}
if ($targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
return $targetUrl;
}
}
Expand Down
Expand Up @@ -83,6 +83,16 @@ public function getRequestRedirections()
array(),
'/',
),
'target path as referer when referer not set' => array(
Request::create('/'),
array('use_referer' => true),
'/',
),
'target path as referer when referer is ?' => array(
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => '?')),
array('use_referer' => true),
'/',
),
'target path should be different than login URL' => array(
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login')),
array('use_referer' => true, 'login_path' => '/login'),
Expand Down

0 comments on commit a29e069

Please sign in to comment.