From f79395851b044689567e0e6c9504acbcaa742782 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Tue, 26 Feb 2019 10:11:12 +1000 Subject: Twig update to latest Twig 1.x legacy as per vichan --- inc/lib/Twig/NodeVisitor/SafeAnalysis.php | 43 +++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'inc/lib/Twig/NodeVisitor/SafeAnalysis.php') diff --git a/inc/lib/Twig/NodeVisitor/SafeAnalysis.php b/inc/lib/Twig/NodeVisitor/SafeAnalysis.php index b0c658cd..ca31c8fc 100644 --- a/inc/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/inc/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -1,6 +1,18 @@ data[$hash])) { - foreach ($this->data[$hash] as $bucket) { - if ($bucket['key'] === $node) { - return $bucket['value']; - } + if (!isset($this->data[$hash])) { + return; + } + + foreach ($this->data[$hash] as $bucket) { + if ($bucket['key'] !== $node) { + continue; } + + if (in_array('html_attr', $bucket['value'])) { + $bucket['value'][] = 'html'; + } + + return $bucket['value']; } } @@ -40,12 +60,12 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface ); } - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doEnterNode(Twig_Node $node, Twig_Environment $env) { return $node; } - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Expression_Constant) { // constants are marked safe for all @@ -89,8 +109,6 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface } else { $this->setSafe($node, array()); } - } elseif ($node instanceof Twig_Node_Expression_MacroCall) { - $this->setSafe($node, array('all')); } elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) { $name = $node->getNode('node')->getAttribute('name'); // attributes on template instances are safe @@ -123,11 +141,10 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface return array_intersect($a, $b); } - /** - * {@inheritdoc} - */ public function getPriority() { return 0; } } + +class_alias('Twig_NodeVisitor_SafeAnalysis', 'Twig\NodeVisitor\SafeAnalysisNodeVisitor', false); -- cgit v1.3