diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index afef4093db..35bd5ef1ef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -146,6 +146,10 @@ class Router extends BaseRouter implements WarmableInterface return '%%'; } + if (preg_match('/^env\(\w+\)$/', $match[1])) { + throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1])); + } + $resolved = $container->getParameter($match[1]); if (is_string($resolved) || is_numeric($resolved)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 330e0659ca..4727fc4b82 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -131,6 +131,20 @@ class RouterTest extends \PHPUnit_Framework_TestCase ); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage Using "%env(FOO)%" is not allowed in routing configuration. + */ + public function testEnvPlaceholders() + { + $routes = new RouteCollection(); + + $routes->add('foo', new Route('/%env(FOO)%')); + + $router = new Router($this->getServiceContainer($routes), 'foo'); + $router->getRouteCollection(); + } + public function testHostPlaceholders() { $routes = new RouteCollection();