ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Escaper.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
16{
18
24 public function __construct($defaultStrategy = 'html')
25 {
27 }
28
29 public function getTokenParsers()
30 {
31 return array(new Twig_TokenParser_AutoEscape());
32 }
33
34 public function getNodeVisitors()
35 {
36 return array(new Twig_NodeVisitor_Escaper());
37 }
38
39 public function getFilters()
40 {
41 return array(
42 new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
43 );
44 }
45
55 {
56 // for BC
57 if (true === $defaultStrategy) {
58 @trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED);
59
60 $defaultStrategy = 'html';
61 }
62
63 if ('filename' === $defaultStrategy) {
64 @trigger_error('Using "filename" as the default strategy is deprecated since version 1.27. Use "name" instead.', E_USER_DEPRECATED);
65
66 $defaultStrategy = 'name';
67 }
68
69 if ('name' === $defaultStrategy) {
70 $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
71 }
72
73 $this->defaultStrategy = $defaultStrategy;
74 }
75
83 public function getDefaultStrategy($name)
84 {
85 // disable string callables to avoid calling a function named html or js,
86 // or any other upcoming escaping strategy
87 if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
88 return call_user_func($this->defaultStrategy, $name);
89 }
90
92 }
93
94 public function getName()
95 {
96 return 'escaper';
97 }
98}
99
107function twig_raw_filter($string)
108{
109 return $string;
110}
111
112class_alias('Twig_Extension_Escaper', 'Twig\Extension\EscaperExtension', false);
An exception for terminatinating execution or to throw for unit testing.
getNodeVisitors()
Returns the node visitor instances to add to the existing list.
Definition: Escaper.php:34
__construct($defaultStrategy='html')
Definition: Escaper.php:24
getDefaultStrategy($name)
Gets the default strategy to use when not defined by the user.
Definition: Escaper.php:83
setDefaultStrategy($defaultStrategy)
Sets the default strategy to use when not defined by the user.
Definition: Escaper.php:54
getFilters()
Returns a list of filters to add to the existing list.
Definition: Escaper.php:39
getTokenParsers()
Returns the token parser instances to add to the existing list.
Definition: Escaper.php:29
Twig_NodeVisitor_Escaper implements output escaping.
Definition: Escaper.php:20
Represents a template filter.
Marks a section of a template to be escaped or not.
Definition: AutoEscape.php:33
if($format !==null) $name
Definition: metadata.php:146
twig_raw_filter($string)
Marks a variable as being safe.
Definition: Escaper.php:107