1: | <?php
|
2: |
|
3: |
|
4: |
|
5: |
|
6: |
|
7: | class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter
|
8: | {
|
9: | |
10: | |
11: |
|
12: | public $name = 'HostBlacklist';
|
13: |
|
14: | |
15: | |
16: |
|
17: | protected $blacklist = array();
|
18: |
|
19: | |
20: | |
21: | |
22: |
|
23: | public function prepare($config)
|
24: | {
|
25: | $this->blacklist = $config->get('URI.HostBlacklist');
|
26: | return true;
|
27: | }
|
28: |
|
29: | |
30: | |
31: | |
32: | |
33: | |
34: |
|
35: | public function filter(&$uri, $config, $context)
|
36: | {
|
37: | foreach ($this->blacklist as $blacklisted_host_fragment) {
|
38: | if ($uri->host !== null && strpos($uri->host, $blacklisted_host_fragment) !== false) {
|
39: | return false;
|
40: | }
|
41: | }
|
42: | return true;
|
43: | }
|
44: | }
|
45: |
|
46: |
|
47: | |