do not reuse internally generated variable names during parsing

This commit is contained in:
Christian Flothmann
2022-02-24 17:25:50 +01:00
parent 1e04274f34
commit 1411c454c1
2 changed files with 34 additions and 2 deletions
+1 -2
View File
@@ -62,7 +62,7 @@ class Parser
public function parse(TokenStream $stream, $test = null, $dropNeedle = false)
{
$vars = get_object_vars($this);
unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']);
unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames'], $vars['varNameSalt']);
$this->stack[] = $vars;
// tag handlers
@@ -92,7 +92,6 @@ class Parser
$this->blockStack = [];
$this->importedSymbols = [[]];
$this->embeddedTemplates = [];
$this->varNameSalt = 0;
try {
$body = $this->subparse($test, $dropNeedle);
@@ -0,0 +1,33 @@
--TEST--
blocks and autoescape
--DEPRECATION--
The "filter" tag in "index.twig" at line 8 is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE--
{% extends 'parent.twig' %}
{% block foo %}
{{ parent() }}
Foo child:
{% filter spaceless %}
something B
{% endfilter %}
{% endblock %}
--TEMPLATE(parent.twig)--
{% block foo %}
Foo Parent:
{% filter spaceless %}
something A
{% endfilter %}
{% endblock %}
--DATA--
return []
--EXPECT--
Foo Parent:
something A
Foo child:
something B