8000 throw LogicException when compiling a route with _fragment as a path … · symfony/symfony@049f0c6 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 049f0c6

Browse files
committed
throw LogicException when compiling a route with _fragment as a path parameter
1 parent 01e0eb1 commit 049f0c6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Symfony/Component/Routing/RouteCompiler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public static function compile(Route $route)
5959
$staticPrefix = $result['staticPrefix'];
6060

6161
$pathVariables = $result['variables'];
62+
63+
foreach ($pathVariables as $pathParam) {
64+
if ('_fragment' == $pathParam) {
65+
throw new \LogicException(sprintf('Route pattern "%s" cannot contain "_fragment" as a path parameter.', $route->getPath()));
66+
}
67+
}
68+
6269
$variables = array_merge($variables, $pathVariables);
6370

6471
$tokens = $result['tokens'];

src/Symfony/Component/Routing/Tests/RouteCompilerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ public function testRouteWithSameVariableTwice()
161161
$compiled = $route->compile();
162162
}
163163

164+
/**
165+
* @expectedException \LogicException
166+
*/
167+
public function testRouteWithFragmentAsPathParameter()
168+
{
169+
$route = new Route('/{_fragment}');
170+
171+
$compiled = $route->compile();
172+
}
173+
164174
/**
165175
* @dataProvider getNumericVariableNames
166176
* @expectedException \DomainException

0 commit comments

Comments
 (0)
0