8000 [Security] ensure the 'route' index is set before attempting to use it by gsdevme · Pull Request #23238 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] ensure the 'route' index is set before attempting to use it #23238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(security): ensure the 'route' index is set before attempting to u…
…se it
  • Loading branch information
gsdevme committed Jul 19, 2017
commit 316e9c781432dfc5ed00173af7f72922c01385a9
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/Http/HttpUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function checkRequestPath(Request $request, $path)
$parameters = $this->urlMatcher->match($request->getPathInfo());
}

return $path === $parameters['_route'];
return isset($parameters['_route']) && $path === $parameters['_route'];
} catch (MethodNotAllowedException $e) {
return false;
} catch (ResourceNotFoundException $e) {
Expand Down
13 changes: 13 additions & 0 deletions 95AF src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ public function testCheckRequestPathWithUrlMatcherLoadingException()
$utils->checkRequestPath($this->getRequest(), 'foobar');
}

public function testCheckPathWithoutRouteParam()
{
$urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
$urlMatcher
->expects($this->any())
->method('match')
->willReturn(array('_controller' => 'PathController'))
;

$utils = new HttpUtils(null, $urlMatcher);
$this->assertFalse($utils->checkRequestPath($this->getRequest(), 'path/index.html'));
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Matcher must either implement UrlMatcherInterface or RequestMatcherInterface
Expand Down
0