Fix sandbox __toString bypasses

This commit is contained in:
Fabien Potencier
2026-05-19 16:49:38 +02:00
parent 7f3056a28e
commit 447d0b2331
35 changed files with 516 additions and 67 deletions
+7 -1
View File
@@ -23,7 +23,7 @@ use Twig\Node\Expression\Variable\ContextVariable;
* @author Fabien Potencier <fabien@symfony.com>
*/
#[YieldReady]
class ImportNode extends Node
class ImportNode extends Node implements CoercesChildrenToStringInterface
{
public function __construct(AbstractExpression $expr, AbstractExpression|AssignTemplateVariable $var, int $lineno)
{
@@ -58,4 +58,10 @@ class ImportNode extends Node
$compiler->raw(";\n");
}
public function getStringCoercedChildNames(): array
{
// the loader resolves the template-name expression by coercing it to a string
return ['expr'];
}
}