From 227d8356faf5f139d8689664c3a6beda36f6618e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 18 May 2022 17:32:23 +0200 Subject: [PATCH] ModifierNode: added $sanitize --- src/Latte/Compiler/Nodes/Php/ModifierNode.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Latte/Compiler/Nodes/Php/ModifierNode.php b/src/Latte/Compiler/Nodes/Php/ModifierNode.php index 7b1acddb65..c00f764689 100644 --- a/src/Latte/Compiler/Nodes/Php/ModifierNode.php +++ b/src/Latte/Compiler/Nodes/Php/ModifierNode.php @@ -20,6 +20,7 @@ public function __construct( /** @var FilterNode[] */ public array $filters, public bool $escape = false, + public bool $sanitize = true, public ?Position $position = null, ) { (function (FilterNode ...$args) {})(...$filters); @@ -46,26 +47,28 @@ public function print(PrintContext $context): string public function printSimple(PrintContext $context, string $expr): string { + $escape = $this->escape; + $sanitize = $this->sanitize; foreach ($this->filters as $filter) { $name = $filter->name->name; if (['nocheck' => 1, 'noCheck' => 1][$name] ?? null) { - $nocheck = true; + $sanitize = false; } elseif ($name === 'noescape') { - $noescape = true; + $escape = false; } else { if (['datastream' => 1, 'dataStream' => 1][$name] ?? null) { - $nocheck = true; + $sanitize = false; } $expr = $filter->printSimple($context, $expr); } } $escaper = $context->getEscaper(); - if (empty($nocheck)) { + if ($sanitize) { $expr = $escaper->sanitize($expr); } - if ($this->escape && empty($noescape)) { + if ($escape) { $expr = $escaper->escape($expr); }