From a3fc63923a98e49d827fa49b74d3c04827edbd6e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 16 Apr 2019 18:55:59 +0200 Subject: [PATCH] fixed EscaperNodeVisitor --- CHANGELOG | 2 +- src/NodeVisitor/EscaperNodeVisitor.php | 2 +- test/Twig/Tests/Fixtures/tags/autoescape/literal.test | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d4d49a5846c..29dc3454c21 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.39.1 (2019-XX-XX) - * n/a + * fixed EscaperNodeVisitor * 1.39.0 (2019-04-16) diff --git a/src/NodeVisitor/EscaperNodeVisitor.php b/src/NodeVisitor/EscaperNodeVisitor.php index 16528bc5c81..f6e16fa7d77 100644 --- a/src/NodeVisitor/EscaperNodeVisitor.php +++ b/src/NodeVisitor/EscaperNodeVisitor.php @@ -108,7 +108,7 @@ private function unwrapConditional(ConditionalExpression $expression, Environmen $expr2 = $this->escapeInlinePrintNode(new InlinePrint($expr2, $expr2->getTemplateLine()), $env, $type); } $expr3 = $expression->getNode('expr3'); - if ($expr3 instanceof ConditionalExpression && $this->shouldUnwrapConditional($expr2, $env, $type)) { + if ($expr3 instanceof ConditionalExpression && $this->shouldUnwrapConditional($expr3, $env, $type)) { $expr3 = $this->unwrapConditional($expr3, $env, $type); } else { $expr3 = $this->escapeInlinePrintNode(new InlinePrint($expr3, $expr3->getTemplateLine()), $env, $type); diff --git a/test/Twig/Tests/Fixtures/tags/autoescape/literal.test b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test index 8f37e38198d..3d8d4f8fdd2 100644 --- a/test/Twig/Tests/Fixtures/tags/autoescape/literal.test +++ b/test/Twig/Tests/Fixtures/tags/autoescape/literal.test @@ -23,12 +23,16 @@ {{ true ? (false ? "
" : someVar) : "\n" }} {{ true ? (true ? someVar : "
") : "\n" }} {{ true ? (false ? someVar : "
") : "\n" }} +{{ false ? "\n" : (true ? someVar : "
") }} +{{ false ? "\n" : (false ? someVar : "
") }} 6. Nested conditionals with a variable marked safe {{ true ? (true ? "
" : someVar|raw) : "\n" }} {{ true ? (false ? "
" : someVar|raw) : "\n" }} {{ true ? (true ? someVar|raw : "
") : "\n" }} {{ true ? (false ? someVar|raw : "
") : "\n" }} +{{ false ? "\n" : (true ? someVar|raw : "
") }} +{{ false ? "\n" : (false ? someVar|raw : "
") }} 7. Without then clause {{ "
" ?: someVar }} @@ -63,12 +67,16 @@ return ['someVar' => '
', 'someFalseVar' => false] <br /> <br />
+<br /> +
6. Nested conditionals with a variable marked safe



+
+
7. Without then clause