Skip to content

Commit 8d80628

Browse files
[FrameworkBundle] Forbid env parameters in routing configuration
1 parent 8a377bb commit 8d80628

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Routing/Router.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ private function resolve($value)
146146
return '%%';
147147
}
148148

149+
if (preg_match('/^env\(\w+\)$/', $match[1])) {
150+
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
151+
}
152+
149153
$resolved = $container->getParameter($match[1]);
150154

151155
if (is_string($resolved) || is_numeric($resolved)) {

Tests/Routing/RouterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ public function testPatternPlaceholders()
131131
);
132132
}
133133

134+
/**
135+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
136+
* @expectedExceptionMessage Using "%env(FOO)%" is not allowed in routing configuration.
137+
*/
138+
public function testEnvPlaceholders()
139+
{
140+
$routes = new RouteCollection();
141+
142+
$routes->add('foo', new Route('/%env(FOO)%'));
143+
144+
$router = new Router($this->getServiceContainer($routes), 'foo');
145+
$router->getRouteCollection();
146+
}
147+
134148
public function testHostPlaceholders()
135149
{
136150
$routes = new RouteCollection();

0 commit comments

Comments
 (0)