Deprecate the fact that the parent, block, and attribute functions are always allowed in a sandboxed template

This commit is contained in:
Fabien Potencier
2026-05-24 21:19:08 +02:00
parent d0a5017fd5
commit cfaa2fd030
6 changed files with 132 additions and 2 deletions
@@ -54,7 +54,13 @@ final class FunctionExpressionParser extends AbstractExpressionParser implements
$fakeNode = new EmptyNode($line);
$fakeNode->setSourceContext($parser->getStream()->getSourceContext());
return ($function->getParserCallable())($parser, $fakeNode, $args, $line);
$node = ($function->getParserCallable())($parser, $fakeNode, $args, $line);
// remember the original function name so the sandbox can enforce
// the `allowedFunctions` allow-list even though the parser callable
// returned a specialized node (e.g. `parent`, `block`, `attribute`).
$node->setAttribute('sandboxed_function_name', $name);
return $node;
}
if (!isset($this->readyNodes[$class = $function->getNodeClass()])) {