@@ -9,11 +9,11 @@ |
||
9 | 9 | */ |
10 | 10 | class HTMLPurifier_Token_End extends HTMLPurifier_Token_Tag |
11 | 11 | { |
12 | - /** |
|
13 | - * Token that started this node. Added by MakeWellFormed. Please |
|
14 | - * do not edit this! |
|
15 | - */ |
|
16 | - public $start; |
|
12 | + /** |
|
13 | + * Token that started this node. Added by MakeWellFormed. Please |
|
14 | + * do not edit this! |
|
15 | + */ |
|
16 | + public $start; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // vim: et sw=4 sts=4 |
@@ -5,53 +5,53 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_Token_Tag extends HTMLPurifier_Token |
7 | 7 | { |
8 | - /** |
|
9 | - * Static bool marker that indicates the class is a tag. |
|
10 | - * |
|
11 | - * This allows us to check objects with <tt>!empty($obj->is_tag)</tt> |
|
12 | - * without having to use a function call <tt>is_a()</tt>. |
|
13 | - */ |
|
14 | - public $is_tag = true; |
|
8 | + /** |
|
9 | + * Static bool marker that indicates the class is a tag. |
|
10 | + * |
|
11 | + * This allows us to check objects with <tt>!empty($obj->is_tag)</tt> |
|
12 | + * without having to use a function call <tt>is_a()</tt>. |
|
13 | + */ |
|
14 | + public $is_tag = true; |
|
15 | 15 | |
16 | - /** |
|
17 | - * The lower-case name of the tag, like 'a', 'b' or 'blockquote'. |
|
18 | - * |
|
19 | - * @note Strictly speaking, XML tags are case sensitive, so we shouldn't |
|
20 | - * be lower-casing them, but these tokens cater to HTML tags, which are |
|
21 | - * insensitive. |
|
22 | - */ |
|
23 | - public $name; |
|
16 | + /** |
|
17 | + * The lower-case name of the tag, like 'a', 'b' or 'blockquote'. |
|
18 | + * |
|
19 | + * @note Strictly speaking, XML tags are case sensitive, so we shouldn't |
|
20 | + * be lower-casing them, but these tokens cater to HTML tags, which are |
|
21 | + * insensitive. |
|
22 | + */ |
|
23 | + public $name; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Associative array of the tag's attributes. |
|
27 | - */ |
|
28 | - public $attr = array(); |
|
25 | + /** |
|
26 | + * Associative array of the tag's attributes. |
|
27 | + */ |
|
28 | + public $attr = array(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * Non-overloaded constructor, which lower-cases passed tag name. |
|
32 | - * |
|
33 | - * @param $name String name. |
|
34 | - * @param $attr Associative array of attributes. |
|
35 | - */ |
|
36 | - public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { |
|
37 | - $this->name = ctype_lower($name) ? $name : strtolower($name); |
|
38 | - foreach ($attr as $key => $value) { |
|
39 | - // normalization only necessary when key is not lowercase |
|
40 | - if (!ctype_lower($key)) { |
|
41 | - $new_key = strtolower($key); |
|
42 | - if (!isset($attr[$new_key])) { |
|
43 | - $attr[$new_key] = $attr[$key]; |
|
44 | - } |
|
45 | - if ($new_key !== $key) { |
|
46 | - unset($attr[$key]); |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
50 | - $this->attr = $attr; |
|
51 | - $this->line = $line; |
|
52 | - $this->col = $col; |
|
53 | - $this->armor = $armor; |
|
54 | - } |
|
30 | + /** |
|
31 | + * Non-overloaded constructor, which lower-cases passed tag name. |
|
32 | + * |
|
33 | + * @param $name String name. |
|
34 | + * @param $attr Associative array of attributes. |
|
35 | + */ |
|
36 | + public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { |
|
37 | + $this->name = ctype_lower($name) ? $name : strtolower($name); |
|
38 | + foreach ($attr as $key => $value) { |
|
39 | + // normalization only necessary when key is not lowercase |
|
40 | + if (!ctype_lower($key)) { |
|
41 | + $new_key = strtolower($key); |
|
42 | + if (!isset($attr[$new_key])) { |
|
43 | + $attr[$new_key] = $attr[$key]; |
|
44 | + } |
|
45 | + if ($new_key !== $key) { |
|
46 | + unset($attr[$key]); |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | + $this->attr = $attr; |
|
51 | + $this->line = $line; |
|
52 | + $this->col = $col; |
|
53 | + $this->armor = $armor; |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // vim: et sw=4 sts=4 |
@@ -12,21 +12,21 @@ |
||
12 | 12 | class HTMLPurifier_Token_Text extends HTMLPurifier_Token |
13 | 13 | { |
14 | 14 | |
15 | - public $name = '#PCDATA'; /**< PCDATA tag name compatible with DTD. */ |
|
16 | - public $data; /**< Parsed character data of text. */ |
|
17 | - public $is_whitespace; /**< Bool indicating if node is whitespace. */ |
|
15 | + public $name = '#PCDATA'; /**< PCDATA tag name compatible with DTD. */ |
|
16 | + public $data; /**< Parsed character data of text. */ |
|
17 | + public $is_whitespace; /**< Bool indicating if node is whitespace. */ |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructor, accepts data and determines if it is whitespace. |
|
21 | - * |
|
22 | - * @param $data String parsed character data. |
|
23 | - */ |
|
24 | - public function __construct($data, $line = null, $col = null) { |
|
25 | - $this->data = $data; |
|
26 | - $this->is_whitespace = ctype_space($data); |
|
27 | - $this->line = $line; |
|
28 | - $this->col = $col; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Constructor, accepts data and determines if it is whitespace. |
|
21 | + * |
|
22 | + * @param $data String parsed character data. |
|
23 | + */ |
|
24 | + public function __construct($data, $line = null, $col = null) { |
|
25 | + $this->data = $data; |
|
26 | + $this->is_whitespace = ctype_space($data); |
|
27 | + $this->line = $line; |
|
28 | + $this->col = $col; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | } |
32 | 32 |
@@ -14,80 +14,80 @@ |
||
14 | 14 | class HTMLPurifier_TokenFactory |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Prototypes that will be cloned. |
|
19 | - * @private |
|
20 | - */ |
|
21 | - // p stands for prototype |
|
22 | - private $p_start, $p_end, $p_empty, $p_text, $p_comment; |
|
17 | + /** |
|
18 | + * Prototypes that will be cloned. |
|
19 | + * @private |
|
20 | + */ |
|
21 | + // p stands for prototype |
|
22 | + private $p_start, $p_end, $p_empty, $p_text, $p_comment; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Generates blank prototypes for cloning. |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - $this->p_start = new HTMLPurifier_Token_Start('', array()); |
|
29 | - $this->p_end = new HTMLPurifier_Token_End(''); |
|
30 | - $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
|
31 | - $this->p_text = new HTMLPurifier_Token_Text(''); |
|
32 | - $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
33 | - } |
|
24 | + /** |
|
25 | + * Generates blank prototypes for cloning. |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + $this->p_start = new HTMLPurifier_Token_Start('', array()); |
|
29 | + $this->p_end = new HTMLPurifier_Token_End(''); |
|
30 | + $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
|
31 | + $this->p_text = new HTMLPurifier_Token_Text(''); |
|
32 | + $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Creates a HTMLPurifier_Token_Start. |
|
37 | - * @param $name Tag name |
|
38 | - * @param $attr Associative array of attributes |
|
39 | - * @return Generated HTMLPurifier_Token_Start |
|
40 | - */ |
|
41 | - public function createStart($name, $attr = array()) { |
|
42 | - $p = clone $this->p_start; |
|
43 | - $p->__construct($name, $attr); |
|
44 | - return $p; |
|
45 | - } |
|
35 | + /** |
|
36 | + * Creates a HTMLPurifier_Token_Start. |
|
37 | + * @param $name Tag name |
|
38 | + * @param $attr Associative array of attributes |
|
39 | + * @return Generated HTMLPurifier_Token_Start |
|
40 | + */ |
|
41 | + public function createStart($name, $attr = array()) { |
|
42 | + $p = clone $this->p_start; |
|
43 | + $p->__construct($name, $attr); |
|
44 | + return $p; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Creates a HTMLPurifier_Token_End. |
|
49 | - * @param $name Tag name |
|
50 | - * @return Generated HTMLPurifier_Token_End |
|
51 | - */ |
|
52 | - public function createEnd($name) { |
|
53 | - $p = clone $this->p_end; |
|
54 | - $p->__construct($name); |
|
55 | - return $p; |
|
56 | - } |
|
47 | + /** |
|
48 | + * Creates a HTMLPurifier_Token_End. |
|
49 | + * @param $name Tag name |
|
50 | + * @return Generated HTMLPurifier_Token_End |
|
51 | + */ |
|
52 | + public function createEnd($name) { |
|
53 | + $p = clone $this->p_end; |
|
54 | + $p->__construct($name); |
|
55 | + return $p; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Creates a HTMLPurifier_Token_Empty. |
|
60 | - * @param $name Tag name |
|
61 | - * @param $attr Associative array of attributes |
|
62 | - * @return Generated HTMLPurifier_Token_Empty |
|
63 | - */ |
|
64 | - public function createEmpty($name, $attr = array()) { |
|
65 | - $p = clone $this->p_empty; |
|
66 | - $p->__construct($name, $attr); |
|
67 | - return $p; |
|
68 | - } |
|
58 | + /** |
|
59 | + * Creates a HTMLPurifier_Token_Empty. |
|
60 | + * @param $name Tag name |
|
61 | + * @param $attr Associative array of attributes |
|
62 | + * @return Generated HTMLPurifier_Token_Empty |
|
63 | + */ |
|
64 | + public function createEmpty($name, $attr = array()) { |
|
65 | + $p = clone $this->p_empty; |
|
66 | + $p->__construct($name, $attr); |
|
67 | + return $p; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Creates a HTMLPurifier_Token_Text. |
|
72 | - * @param $data Data of text token |
|
73 | - * @return Generated HTMLPurifier_Token_Text |
|
74 | - */ |
|
75 | - public function createText($data) { |
|
76 | - $p = clone $this->p_text; |
|
77 | - $p->__construct($data); |
|
78 | - return $p; |
|
79 | - } |
|
70 | + /** |
|
71 | + * Creates a HTMLPurifier_Token_Text. |
|
72 | + * @param $data Data of text token |
|
73 | + * @return Generated HTMLPurifier_Token_Text |
|
74 | + */ |
|
75 | + public function createText($data) { |
|
76 | + $p = clone $this->p_text; |
|
77 | + $p->__construct($data); |
|
78 | + return $p; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Creates a HTMLPurifier_Token_Comment. |
|
83 | - * @param $data Data of comment token |
|
84 | - * @return Generated HTMLPurifier_Token_Comment |
|
85 | - */ |
|
86 | - public function createComment($data) { |
|
87 | - $p = clone $this->p_comment; |
|
88 | - $p->__construct($data); |
|
89 | - return $p; |
|
90 | - } |
|
81 | + /** |
|
82 | + * Creates a HTMLPurifier_Token_Comment. |
|
83 | + * @param $data Data of comment token |
|
84 | + * @return Generated HTMLPurifier_Token_Comment |
|
85 | + */ |
|
86 | + public function createComment($data) { |
|
87 | + $p = clone $this->p_comment; |
|
88 | + $p->__construct($data); |
|
89 | + return $p; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
93 | 93 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $this->p_end = new HTMLPurifier_Token_End(''); |
30 | 30 | $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
31 | 31 | $this->p_text = new HTMLPurifier_Token_Text(''); |
32 | - $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
32 | + $this->p_comment = new HTMLPurifier_Token_Comment(''); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -3,99 +3,99 @@ |
||
3 | 3 | class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition |
4 | 4 | { |
5 | 5 | |
6 | - public $type = 'URI'; |
|
7 | - protected $filters = array(); |
|
8 | - protected $postFilters = array(); |
|
9 | - protected $registeredFilters = array(); |
|
10 | - |
|
11 | - /** |
|
12 | - * HTMLPurifier_URI object of the base specified at %URI.Base |
|
13 | - */ |
|
14 | - public $base; |
|
15 | - |
|
16 | - /** |
|
17 | - * String host to consider "home" base, derived off of $base |
|
18 | - */ |
|
19 | - public $host; |
|
20 | - |
|
21 | - /** |
|
22 | - * Name of default scheme based on %URI.DefaultScheme and %URI.Base |
|
23 | - */ |
|
24 | - public $defaultScheme; |
|
25 | - |
|
26 | - public function __construct() { |
|
27 | - $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternal()); |
|
28 | - $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternalResources()); |
|
29 | - $this->registerFilter(new HTMLPurifier_URIFilter_HostBlacklist()); |
|
30 | - $this->registerFilter(new HTMLPurifier_URIFilter_SafeIframe()); |
|
31 | - $this->registerFilter(new HTMLPurifier_URIFilter_MakeAbsolute()); |
|
32 | - $this->registerFilter(new HTMLPurifier_URIFilter_Munge()); |
|
33 | - } |
|
34 | - |
|
35 | - public function registerFilter($filter) { |
|
36 | - $this->registeredFilters[$filter->name] = $filter; |
|
37 | - } |
|
38 | - |
|
39 | - public function addFilter($filter, $config) { |
|
40 | - $r = $filter->prepare($config); |
|
41 | - if ($r === false) return; // null is ok, for backwards compat |
|
42 | - if ($filter->post) { |
|
43 | - $this->postFilters[$filter->name] = $filter; |
|
44 | - } else { |
|
45 | - $this->filters[$filter->name] = $filter; |
|
46 | - } |
|
47 | - } |
|
48 | - |
|
49 | - protected function doSetup($config) { |
|
50 | - $this->setupMemberVariables($config); |
|
51 | - $this->setupFilters($config); |
|
52 | - } |
|
53 | - |
|
54 | - protected function setupFilters($config) { |
|
55 | - foreach ($this->registeredFilters as $name => $filter) { |
|
56 | - if ($filter->always_load) { |
|
57 | - $this->addFilter($filter, $config); |
|
58 | - } else { |
|
59 | - $conf = $config->get('URI.' . $name); |
|
60 | - if ($conf !== false && $conf !== null) { |
|
61 | - $this->addFilter($filter, $config); |
|
62 | - } |
|
63 | - } |
|
64 | - } |
|
65 | - unset($this->registeredFilters); |
|
66 | - } |
|
67 | - |
|
68 | - protected function setupMemberVariables($config) { |
|
69 | - $this->host = $config->get('URI.Host'); |
|
70 | - $base_uri = $config->get('URI.Base'); |
|
71 | - if (!is_null($base_uri)) { |
|
72 | - $parser = new HTMLPurifier_URIParser(); |
|
73 | - $this->base = $parser->parse($base_uri); |
|
74 | - $this->defaultScheme = $this->base->scheme; |
|
75 | - if (is_null($this->host)) $this->host = $this->base->host; |
|
76 | - } |
|
77 | - if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
78 | - } |
|
79 | - |
|
80 | - public function getDefaultScheme($config, $context) { |
|
81 | - return HTMLPurifier_URISchemeRegistry::instance()->getScheme($this->defaultScheme, $config, $context); |
|
82 | - } |
|
83 | - |
|
84 | - public function filter(&$uri, $config, $context) { |
|
85 | - foreach ($this->filters as $name => $f) { |
|
86 | - $result = $f->filter($uri, $config, $context); |
|
87 | - if (!$result) return false; |
|
88 | - } |
|
89 | - return true; |
|
90 | - } |
|
91 | - |
|
92 | - public function postFilter(&$uri, $config, $context) { |
|
93 | - foreach ($this->postFilters as $name => $f) { |
|
94 | - $result = $f->filter($uri, $config, $context); |
|
95 | - if (!$result) return false; |
|
96 | - } |
|
97 | - return true; |
|
98 | - } |
|
6 | + public $type = 'URI'; |
|
7 | + protected $filters = array(); |
|
8 | + protected $postFilters = array(); |
|
9 | + protected $registeredFilters = array(); |
|
10 | + |
|
11 | + /** |
|
12 | + * HTMLPurifier_URI object of the base specified at %URI.Base |
|
13 | + */ |
|
14 | + public $base; |
|
15 | + |
|
16 | + /** |
|
17 | + * String host to consider "home" base, derived off of $base |
|
18 | + */ |
|
19 | + public $host; |
|
20 | + |
|
21 | + /** |
|
22 | + * Name of default scheme based on %URI.DefaultScheme and %URI.Base |
|
23 | + */ |
|
24 | + public $defaultScheme; |
|
25 | + |
|
26 | + public function __construct() { |
|
27 | + $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternal()); |
|
28 | + $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternalResources()); |
|
29 | + $this->registerFilter(new HTMLPurifier_URIFilter_HostBlacklist()); |
|
30 | + $this->registerFilter(new HTMLPurifier_URIFilter_SafeIframe()); |
|
31 | + $this->registerFilter(new HTMLPurifier_URIFilter_MakeAbsolute()); |
|
32 | + $this->registerFilter(new HTMLPurifier_URIFilter_Munge()); |
|
33 | + } |
|
34 | + |
|
35 | + public function registerFilter($filter) { |
|
36 | + $this->registeredFilters[$filter->name] = $filter; |
|
37 | + } |
|
38 | + |
|
39 | + public function addFilter($filter, $config) { |
|
40 | + $r = $filter->prepare($config); |
|
41 | + if ($r === false) return; // null is ok, for backwards compat |
|
42 | + if ($filter->post) { |
|
43 | + $this->postFilters[$filter->name] = $filter; |
|
44 | + } else { |
|
45 | + $this->filters[$filter->name] = $filter; |
|
46 | + } |
|
47 | + } |
|
48 | + |
|
49 | + protected function doSetup($config) { |
|
50 | + $this->setupMemberVariables($config); |
|
51 | + $this->setupFilters($config); |
|
52 | + } |
|
53 | + |
|
54 | + protected function setupFilters($config) { |
|
55 | + foreach ($this->registeredFilters as $name => $filter) { |
|
56 | + if ($filter->always_load) { |
|
57 | + $this->addFilter($filter, $config); |
|
58 | + } else { |
|
59 | + $conf = $config->get('URI.' . $name); |
|
60 | + if ($conf !== false && $conf !== null) { |
|
61 | + $this->addFilter($filter, $config); |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | + unset($this->registeredFilters); |
|
66 | + } |
|
67 | + |
|
68 | + protected function setupMemberVariables($config) { |
|
69 | + $this->host = $config->get('URI.Host'); |
|
70 | + $base_uri = $config->get('URI.Base'); |
|
71 | + if (!is_null($base_uri)) { |
|
72 | + $parser = new HTMLPurifier_URIParser(); |
|
73 | + $this->base = $parser->parse($base_uri); |
|
74 | + $this->defaultScheme = $this->base->scheme; |
|
75 | + if (is_null($this->host)) $this->host = $this->base->host; |
|
76 | + } |
|
77 | + if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
78 | + } |
|
79 | + |
|
80 | + public function getDefaultScheme($config, $context) { |
|
81 | + return HTMLPurifier_URISchemeRegistry::instance()->getScheme($this->defaultScheme, $config, $context); |
|
82 | + } |
|
83 | + |
|
84 | + public function filter(&$uri, $config, $context) { |
|
85 | + foreach ($this->filters as $name => $f) { |
|
86 | + $result = $f->filter($uri, $config, $context); |
|
87 | + if (!$result) return false; |
|
88 | + } |
|
89 | + return true; |
|
90 | + } |
|
91 | + |
|
92 | + public function postFilter(&$uri, $config, $context) { |
|
93 | + foreach ($this->postFilters as $name => $f) { |
|
94 | + $result = $f->filter($uri, $config, $context); |
|
95 | + if (!$result) return false; |
|
96 | + } |
|
97 | + return true; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } |
101 | 101 |
@@ -38,7 +38,10 @@ discard block |
||
38 | 38 | |
39 | 39 | public function addFilter($filter, $config) { |
40 | 40 | $r = $filter->prepare($config); |
41 | - if ($r === false) return; // null is ok, for backwards compat |
|
41 | + if ($r === false) { |
|
42 | + return; |
|
43 | + } |
|
44 | + // null is ok, for backwards compat |
|
42 | 45 | if ($filter->post) { |
43 | 46 | $this->postFilters[$filter->name] = $filter; |
44 | 47 | } else { |
@@ -72,9 +75,13 @@ discard block |
||
72 | 75 | $parser = new HTMLPurifier_URIParser(); |
73 | 76 | $this->base = $parser->parse($base_uri); |
74 | 77 | $this->defaultScheme = $this->base->scheme; |
75 | - if (is_null($this->host)) $this->host = $this->base->host; |
|
78 | + if (is_null($this->host)) { |
|
79 | + $this->host = $this->base->host; |
|
80 | + } |
|
81 | + } |
|
82 | + if (is_null($this->defaultScheme)) { |
|
83 | + $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
76 | 84 | } |
77 | - if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
78 | 85 | } |
79 | 86 | |
80 | 87 | public function getDefaultScheme($config, $context) { |
@@ -84,7 +91,9 @@ discard block |
||
84 | 91 | public function filter(&$uri, $config, $context) { |
85 | 92 | foreach ($this->filters as $name => $f) { |
86 | 93 | $result = $f->filter($uri, $config, $context); |
87 | - if (!$result) return false; |
|
94 | + if (!$result) { |
|
95 | + return false; |
|
96 | + } |
|
88 | 97 | } |
89 | 98 | return true; |
90 | 99 | } |
@@ -92,7 +101,9 @@ discard block |
||
92 | 101 | public function postFilter(&$uri, $config, $context) { |
93 | 102 | foreach ($this->postFilters as $name => $f) { |
94 | 103 | $result = $f->filter($uri, $config, $context); |
95 | - if (!$result) return false; |
|
104 | + if (!$result) { |
|
105 | + return false; |
|
106 | + } |
|
96 | 107 | } |
97 | 108 | return true; |
98 | 109 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if ($filter->always_load) { |
57 | 57 | $this->addFilter($filter, $config); |
58 | 58 | } else { |
59 | - $conf = $config->get('URI.' . $name); |
|
59 | + $conf = $config->get('URI.'.$name); |
|
60 | 60 | if ($conf !== false && $conf !== null) { |
61 | 61 | $this->addFilter($filter, $config); |
62 | 62 | } |
@@ -28,39 +28,39 @@ |
||
28 | 28 | abstract class HTMLPurifier_URIFilter |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * Unique identifier of filter |
|
33 | - */ |
|
34 | - public $name; |
|
31 | + /** |
|
32 | + * Unique identifier of filter |
|
33 | + */ |
|
34 | + public $name; |
|
35 | 35 | |
36 | - /** |
|
37 | - * True if this filter should be run after scheme validation. |
|
38 | - */ |
|
39 | - public $post = false; |
|
36 | + /** |
|
37 | + * True if this filter should be run after scheme validation. |
|
38 | + */ |
|
39 | + public $post = false; |
|
40 | 40 | |
41 | - /** |
|
42 | - * True if this filter should always be loaded (this permits |
|
43 | - * a filter to be named Foo without the corresponding %URI.Foo |
|
44 | - * directive existing.) |
|
45 | - */ |
|
46 | - public $always_load = false; |
|
41 | + /** |
|
42 | + * True if this filter should always be loaded (this permits |
|
43 | + * a filter to be named Foo without the corresponding %URI.Foo |
|
44 | + * directive existing.) |
|
45 | + */ |
|
46 | + public $always_load = false; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Performs initialization for the filter. If the filter returns |
|
50 | - * false, this means that it shouldn't be considered active. |
|
51 | - */ |
|
52 | - public function prepare($config) {return true;} |
|
48 | + /** |
|
49 | + * Performs initialization for the filter. If the filter returns |
|
50 | + * false, this means that it shouldn't be considered active. |
|
51 | + */ |
|
52 | + public function prepare($config) {return true;} |
|
53 | 53 | |
54 | - /** |
|
55 | - * Filter a URI object |
|
56 | - * @param $uri Reference to URI object variable |
|
57 | - * @param $config Instance of HTMLPurifier_Config |
|
58 | - * @param $context Instance of HTMLPurifier_Context |
|
59 | - * @return bool Whether or not to continue processing: false indicates |
|
60 | - * URL is no good, true indicates continue processing. Note that |
|
61 | - * all changes are committed directly on the URI object |
|
62 | - */ |
|
63 | - abstract public function filter(&$uri, $config, $context); |
|
54 | + /** |
|
55 | + * Filter a URI object |
|
56 | + * @param $uri Reference to URI object variable |
|
57 | + * @param $config Instance of HTMLPurifier_Config |
|
58 | + * @param $context Instance of HTMLPurifier_Context |
|
59 | + * @return bool Whether or not to continue processing: false indicates |
|
60 | + * URL is no good, true indicates continue processing. Note that |
|
61 | + * all changes are committed directly on the URI object |
|
62 | + */ |
|
63 | + abstract public function filter(&$uri, $config, $context); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * Performs initialization for the filter. If the filter returns |
50 | 50 | * false, this means that it shouldn't be considered active. |
51 | 51 | */ |
52 | - public function prepare($config) {return true;} |
|
52 | + public function prepare($config) {return true; } |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Filter a URI object |
@@ -2,22 +2,22 @@ |
||
2 | 2 | |
3 | 3 | class HTMLPurifier_URIFilter_DisableExternal extends HTMLPurifier_URIFilter |
4 | 4 | { |
5 | - public $name = 'DisableExternal'; |
|
6 | - protected $ourHostParts = false; |
|
7 | - public function prepare($config) { |
|
8 | - $our_host = $config->getDefinition('URI')->host; |
|
9 | - if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host)); |
|
10 | - } |
|
11 | - public function filter(&$uri, $config, $context) { |
|
12 | - if (is_null($uri->host)) return true; |
|
13 | - if ($this->ourHostParts === false) return false; |
|
14 | - $host_parts = array_reverse(explode('.', $uri->host)); |
|
15 | - foreach ($this->ourHostParts as $i => $x) { |
|
16 | - if (!isset($host_parts[$i])) return false; |
|
17 | - if ($host_parts[$i] != $this->ourHostParts[$i]) return false; |
|
18 | - } |
|
19 | - return true; |
|
20 | - } |
|
5 | + public $name = 'DisableExternal'; |
|
6 | + protected $ourHostParts = false; |
|
7 | + public function prepare($config) { |
|
8 | + $our_host = $config->getDefinition('URI')->host; |
|
9 | + if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host)); |
|
10 | + } |
|
11 | + public function filter(&$uri, $config, $context) { |
|
12 | + if (is_null($uri->host)) return true; |
|
13 | + if ($this->ourHostParts === false) return false; |
|
14 | + $host_parts = array_reverse(explode('.', $uri->host)); |
|
15 | + foreach ($this->ourHostParts as $i => $x) { |
|
16 | + if (!isset($host_parts[$i])) return false; |
|
17 | + if ($host_parts[$i] != $this->ourHostParts[$i]) return false; |
|
18 | + } |
|
19 | + return true; |
|
20 | + } |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | // vim: et sw=4 sts=4 |
@@ -6,15 +6,25 @@ |
||
6 | 6 | protected $ourHostParts = false; |
7 | 7 | public function prepare($config) { |
8 | 8 | $our_host = $config->getDefinition('URI')->host; |
9 | - if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host)); |
|
9 | + if ($our_host !== null) { |
|
10 | + $this->ourHostParts = array_reverse(explode('.', $our_host)); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | public function filter(&$uri, $config, $context) { |
12 | - if (is_null($uri->host)) return true; |
|
13 | - if ($this->ourHostParts === false) return false; |
|
14 | + if (is_null($uri->host)) { |
|
15 | + return true; |
|
16 | + } |
|
17 | + if ($this->ourHostParts === false) { |
|
18 | + return false; |
|
19 | + } |
|
14 | 20 | $host_parts = array_reverse(explode('.', $uri->host)); |
15 | 21 | foreach ($this->ourHostParts as $i => $x) { |
16 | - if (!isset($host_parts[$i])) return false; |
|
17 | - if ($host_parts[$i] != $this->ourHostParts[$i]) return false; |
|
22 | + if (!isset($host_parts[$i])) { |
|
23 | + return false; |
|
24 | + } |
|
25 | + if ($host_parts[$i] != $this->ourHostParts[$i]) { |
|
26 | + return false; |
|
27 | + } |
|
18 | 28 | } |
19 | 29 | return true; |
20 | 30 | } |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | class HTMLPurifier_URIFilter_DisableExternalResources extends HTMLPurifier_URIFilter_DisableExternal |
4 | 4 | { |
5 | - public $name = 'DisableExternalResources'; |
|
6 | - public function filter(&$uri, $config, $context) { |
|
7 | - if (!$context->get('EmbeddedURI', true)) return true; |
|
8 | - return parent::filter($uri, $config, $context); |
|
9 | - } |
|
5 | + public $name = 'DisableExternalResources'; |
|
6 | + public function filter(&$uri, $config, $context) { |
|
7 | + if (!$context->get('EmbeddedURI', true)) return true; |
|
8 | + return parent::filter($uri, $config, $context); |
|
9 | + } |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | // vim: et sw=4 sts=4 |
@@ -4,7 +4,9 @@ |
||
4 | 4 | { |
5 | 5 | public $name = 'DisableExternalResources'; |
6 | 6 | public function filter(&$uri, $config, $context) { |
7 | - if (!$context->get('EmbeddedURI', true)) return true; |
|
7 | + if (!$context->get('EmbeddedURI', true)) { |
|
8 | + return true; |
|
9 | + } |
|
8 | 10 | return parent::filter($uri, $config, $context); |
9 | 11 | } |
10 | 12 | } |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | class HTMLPurifier_URIFilter_DisableResources extends HTMLPurifier_URIFilter |
4 | 4 | { |
5 | - public $name = 'DisableResources'; |
|
6 | - public function filter(&$uri, $config, $context) { |
|
7 | - return !$context->get('EmbeddedURI', true); |
|
8 | - } |
|
5 | + public $name = 'DisableResources'; |
|
6 | + public function filter(&$uri, $config, $context) { |
|
7 | + return !$context->get('EmbeddedURI', true); |
|
8 | + } |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | // vim: et sw=4 sts=4 |