[FrameworkBundle] Forbid env parameters in routing configuration
This commit is contained in:
parent
bd5af67f08
commit
a931002ca2
@ -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)) {
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user