1: | <?php
|
2: |
|
3: | |
4: | |
5: | |
6: | |
7: | |
8: |
|
9: | class HTMLPurifier_URIFilter_SafeIframe extends HTMLPurifier_URIFilter
|
10: | {
|
11: | |
12: | |
13: |
|
14: | public $name = 'SafeIframe';
|
15: |
|
16: | |
17: | |
18: |
|
19: | public $always_load = true;
|
20: |
|
21: | |
22: | |
23: |
|
24: | protected $regexp = null;
|
25: |
|
26: |
|
27: |
|
28: |
|
29: | |
30: | |
31: | |
32: |
|
33: | public function prepare($config)
|
34: | {
|
35: | $this->regexp = $config->get('URI.SafeIframeRegexp');
|
36: | return true;
|
37: | }
|
38: |
|
39: | |
40: | |
41: | |
42: | |
43: | |
44: |
|
45: | public function filter(&$uri, $config, $context)
|
46: | {
|
47: |
|
48: | if (!$config->get('HTML.SafeIframe')) {
|
49: | return true;
|
50: | }
|
51: |
|
52: | if (!$context->get('EmbeddedURI', true)) {
|
53: | return true;
|
54: | }
|
55: | $token = $context->get('CurrentToken', true);
|
56: | if (!($token && $token->name == 'iframe')) {
|
57: | return true;
|
58: | }
|
59: |
|
60: | if ($this->regexp === null) {
|
61: | return false;
|
62: | }
|
63: |
|
64: | return preg_match($this->regexp, $uri->toString());
|
65: | }
|
66: | }
|
67: |
|
68: |
|
69: | |