]> git.wh0rd.org - tt-rss.git/blame - plugins/no_iframes/init.php
pngcrush.sh
[tt-rss.git] / plugins / no_iframes / init.php
CommitLineData
615a6cac
AD
1<?php
2class No_Iframes extends Plugin {
3 private $host;
4
5 function about() {
6 return array(1.0,
e8a0d290 7 "Remove embedded iframes (unless whitelisted)",
615a6cac
AD
8 "fox");
9 }
10
11 function init($host) {
12 $this->host = $host;
13
14 $host->add_hook($host::HOOK_SANITIZE, $this);
15 }
16
21ce7d9e
AD
17 /**
18 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
19 */
615a6cac
AD
20 function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
21
e8a0d290
AD
22 $xpath = new DOMXpath($doc);
23 $entries = $xpath->query('//iframe');
24
25 foreach ($entries as $entry) {
26 if (!iframe_whitelisted($entry))
27 $entry->parentNode->removeChild($entry);
28 }
615a6cac
AD
29
30 return array($doc, $allowed_elements, $disallowed_attributes);
31 }
32
33 function api_version() {
34 return 2;
35 }
36
21ce7d9e 37}