2013-08-01 10:52:51 +02:00
|
|
|
<?php
|
|
|
|
class No_Iframes extends Plugin {
|
|
|
|
private $host;
|
|
|
|
|
|
|
|
function about() {
|
|
|
|
return array(1.0,
|
2014-11-25 16:40:19 +01:00
|
|
|
"Remove embedded iframes (unless whitelisted)",
|
2013-08-01 10:52:51 +02:00
|
|
|
"fox");
|
|
|
|
}
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$this->host = $host;
|
|
|
|
|
|
|
|
$host->add_hook($host::HOOK_SANITIZE, $this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
|
|
|
|
|
2014-11-25 16:40:19 +01:00
|
|
|
$xpath = new DOMXpath($doc);
|
|
|
|
$entries = $xpath->query('//iframe');
|
|
|
|
|
|
|
|
foreach ($entries as $entry) {
|
|
|
|
if (!iframe_whitelisted($entry))
|
|
|
|
$entry->parentNode->removeChild($entry);
|
|
|
|
}
|
2013-08-01 10:52:51 +02:00
|
|
|
|
|
|
|
return array($doc, $allowed_elements, $disallowed_attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
function api_version() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|