Skip to content

Commit

Permalink
fixed EscaperNodeVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 16, 2019
1 parent 072c628 commit a3fc639
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* 1.39.1 (2019-XX-XX)

* n/a
* fixed EscaperNodeVisitor

* 1.39.0 (2019-04-16)

Expand Down
2 changes: 1 addition & 1 deletion src/NodeVisitor/EscaperNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions test/Twig/Tests/Fixtures/tags/autoescape/literal.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@
{{ true ? (false ? "<br />" : someVar) : "\n" }}
{{ true ? (true ? someVar : "<br />") : "\n" }}
{{ true ? (false ? someVar : "<br />") : "\n" }}
{{ false ? "\n" : (true ? someVar : "<br />") }}
{{ false ? "\n" : (false ? someVar : "<br />") }}

6. Nested conditionals with a variable marked safe
{{ true ? (true ? "<br />" : someVar|raw) : "\n" }}
{{ true ? (false ? "<br />" : someVar|raw) : "\n" }}
{{ true ? (true ? someVar|raw : "<br />") : "\n" }}
{{ true ? (false ? someVar|raw : "<br />") : "\n" }}
{{ false ? "\n" : (true ? someVar|raw : "<br />") }}
{{ false ? "\n" : (false ? someVar|raw : "<br />") }}

7. Without then clause
{{ "<br />" ?: someVar }}
Expand Down Expand Up @@ -63,12 +67,16 @@ return ['someVar' => '<br />', 'someFalseVar' => false]
&lt;br /&gt;
&lt;br /&gt;
<br />
&lt;br /&gt;
<br />

6. Nested conditionals with a variable marked safe
<br />
<br />
<br />
<br />
<br />
<br />

7. Without then clause
<br />
Expand Down

0 comments on commit a3fc639

Please sign in to comment.