mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-06 03:47:04 +00:00
Fix sandbox filter/tag/function allow-list bypass when sandbox state changes between renders
This commit is contained in:
@@ -38,8 +38,6 @@ class IncludeNode extends Node implements NodeOutputInterface, CoercesChildrenTo
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$sandboxed = $this->hasAttribute('sandboxed') && $this->getAttribute('sandboxed');
|
||||
|
||||
if ($this->getAttribute('ignore_missing')) {
|
||||
$template = $compiler->getVarName();
|
||||
|
||||
@@ -64,10 +62,6 @@ class IncludeNode extends Node implements NodeOutputInterface, CoercesChildrenTo
|
||||
->indent()
|
||||
;
|
||||
|
||||
if ($sandboxed) {
|
||||
$compiler->write(\sprintf("\$%s->unwrap()->checkSecurity();\n", $template));
|
||||
}
|
||||
|
||||
$compiler->write(\sprintf('yield from $%s->unwrap()->yield(', $template));
|
||||
|
||||
$this->addTemplateArguments($compiler);
|
||||
@@ -76,18 +70,6 @@ class IncludeNode extends Node implements NodeOutputInterface, CoercesChildrenTo
|
||||
->outdent()
|
||||
->write("}\n")
|
||||
;
|
||||
} elseif ($sandboxed) {
|
||||
$template = $compiler->getVarName();
|
||||
|
||||
$compiler->write(\sprintf('$%s = ', $template));
|
||||
$this->addGetTemplate($compiler);
|
||||
$compiler
|
||||
->raw(";\n")
|
||||
->write(\sprintf("\$%s->unwrap()->checkSecurity();\n", $template))
|
||||
->write(\sprintf('yield from $%s->unwrap()->yield(', $template))
|
||||
;
|
||||
$this->addTemplateArguments($compiler);
|
||||
$compiler->raw(");\n");
|
||||
} else {
|
||||
$compiler->write('yield from ');
|
||||
$this->addGetTemplate($compiler);
|
||||
|
||||
Reference in New Issue
Block a user