} else {
$this->setSafe($node, array());
}
+ } elseif ($node instanceof Twig_Node_Expression_Function) {
+ // function expression is safe when the function is safe
+ $name = $node->getNode('name')->getAttribute('name');
+ $args = $node->getNode('arguments');
+ $function = $env->getFunction($name);
+ if (null !== $function) {
+ $this->setSafe($node, $function->getSafe($args));
+ } else {
+ $this->setSafe($node, array());
+ }
} else {
$this->setSafe($node, array());
}
--- /dev/null
+--TEST--
+"autoescape" tag applies escaping after calling functions
+--TEMPLATE--
+
+autoescape off
+{% autoescape off %}
+
+safe_br
+{{ safe_br() }}
+
+unsafe_br
+{{ unsafe_br() }}
+
+{% endautoescape %}
+
+autoescape on
+{% autoescape on %}
+
+safe_br
+{{ safe_br() }}
+
+unsafe_br
+{{ unsafe_br() }}
+
+unsafe_br()|raw
+{{ (unsafe_br())|raw }}
+
+safe_br()|escape
+{{ (safe_br())|escape }}
+
+safe_br()|raw
+{{ (safe_br())|raw }}
+
+unsafe_br()|escape
+{{ (unsafe_br())|escape }}
+
+{% endautoescape %}
+
+autoescape on js
+{% autoescape on js %}
+
+safe_br
+{{ safe_br() }}
+
+{% endautoescape %}
+--DATA--
+return array()
+--EXPECT--
+
+autoescape off
+
+safe_br
+<br />
+
+unsafe_br
+<br />
+
+
+autoescape on
+
+safe_br
+<br />
+
+unsafe_br
+<br />
+
+unsafe_br()|raw
+<br />
+
+safe_br()|escape
+<br />
+
+safe_br()|raw
+<br />
+
+unsafe_br()|escape
+<br />
+
+
+autoescape on js
+
+safe_br
+\x3cbr \x2f\x3e