Browse code

Made the include function safe for the autoescaping

This fixes a regression introduced in ba88c75557
Fixes #1097

Christophe Coevoet authored on 29/05/2013 13:08:43
Showing 2 changed files
... ...
@@ -191,7 +191,7 @@ class Twig_Extension_Core extends Twig_Extension
191 191
             new Twig_SimpleFunction('cycle', 'twig_cycle'),
192 192
             new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)),
193 193
             new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)),
194
-            new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true)),
194
+            new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
195 195
         );
196 196
     }
197 197
 
... ...
@@ -1273,11 +1273,11 @@ function twig_test_iterable($value)
1273 1273
 /**
1274 1274
  * Renders a template.
1275 1275
  *
1276
- * @param string  template       The template to render
1277
- * @param array   variables      The variables to pass to the template
1278
- * @param Boolean with_context   Whether to pass the current context variables or not
1279
- * @param Boolean ignore_missing Whether to ignore missing templates or not
1280
- * @param Boolean sandboxed      Whether to sandbox the template or not
1276
+ * @param string  $template       The template to render
1277
+ * @param array   $variables      The variables to pass to the template
1278
+ * @param Boolean $with_context   Whether to pass the current context variables or not
1279
+ * @param Boolean $ignore_missing Whether to ignore missing templates or not
1280
+ * @param Boolean $sandboxed      Whether to sandbox the template or not
1281 1281
  *
1282 1282
  * @return string The rendered template
1283 1283
  */
1284 1284
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+--TEST--
2
+"include" function is safe for auto-escaping
3
+--TEMPLATE--
4
+{{ include("foo.twig") }}
5
+--TEMPLATE(foo.twig)--
6
+<p>Test</p>
7
+--DATA--
8
+return array()
9
+--EXPECT--
10
+<p>Test</p>