Skip to content

Commit

Permalink
Fix a potential error if the URL has percentage in it
Browse files Browse the repository at this point in the history
  • Loading branch information
qzminski authored and aschempp committed Aug 3, 2020
1 parent 5d53b99 commit 8ae2582
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core-bundle/src/Routing/RouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function getRouteCollectionForRequest(Request $request): RouteCollection

$pathInfo = rawurldecode($request->getPathInfo());

// The request string must not contain "auto_item" (see #4012)
if (false !== strpos($pathInfo, '/auto_item/')) {
// The request string must not contain "auto_item" (see #4012) or a percentage character
if (false !== strpos($pathInfo, '/auto_item/') || false !== strpos($pathInfo, '%')) {
return new RouteCollection();
}

Expand Down
7 changes: 7 additions & 0 deletions core-bundle/tests/Routing/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ public function testReturnsAnEmptyCollectionIfThePathContainsAutoItem(): void
$this->assertEmpty($this->getRouteProvider()->getRouteCollectionForRequest($request));
}

public function testReturnsAnEmptyCollectionIfThePathContainsPercentageCharacter(): void
{
$request = $this->mockRequestWithPath('/drachenlochmuseum-v%25c3%25a4ttis.html');

$this->assertEmpty($this->getRouteProvider()->getRouteCollectionForRequest($request));
}

public function testReturnsAnEmptyCollectionIfTheUrlSuffixDoesNotMatch(): void
{
$request = $this->mockRequestWithPath('/foo.php');
Expand Down

0 comments on commit 8ae2582

Please sign in to comment.