8000 bug #20687 [FrameworkBundle] Forbid env parameters in routing configu… · symfony/symfony@c500a3e · GitHub
[go: up one dir, main page]

Skip to content

Commit c500a3e

Browse files
committed
bug #20687 [FrameworkBundle] Forbid env parameters in routing configuration (nicolas-grekas)
This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] Forbid env parameters in routing configuration | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20682 | License | MIT | Doc PR | - Commits ------- a931002 [FrameworkBundle] Forbid env parameters in routing configuration
2 parents 0e12427 + a931002 commit c500a3e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/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)) {

src/Symfony/Bundle/FrameworkBundle/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)
0