2013-08-01 08:52:51 +00:00
|
|
|
<?php
|
|
|
|
class No_Iframes extends Plugin {
|
|
|
|
|
|
|
|
function about() {
|
2021-03-01 09:11:42 +00:00
|
|
|
return array(null,
|
2014-11-25 15:40:19 +00:00
|
|
|
"Remove embedded iframes (unless whitelisted)",
|
2013-08-01 08:52:51 +00:00
|
|
|
"fox");
|
|
|
|
}
|
|
|
|
|
|
|
|
function init($host) {
|
|
|
|
$host->add_hook($host::HOOK_SANITIZE, $this);
|
|
|
|
}
|
|
|
|
|
2021-11-14 08:11:49 +00:00
|
|
|
function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
|
2013-08-01 08:52:51 +00:00
|
|
|
|
2014-11-25 15:40:19 +00:00
|
|
|
$xpath = new DOMXpath($doc);
|
|
|
|
$entries = $xpath->query('//iframe');
|
|
|
|
|
|
|
|
foreach ($entries as $entry) {
|
2020-09-22 06:04:33 +00:00
|
|
|
if (!Sanitizer::iframe_whitelisted($entry))
|
2014-11-25 15:40:19 +00:00
|
|
|
$entry->parentNode->removeChild($entry);
|
|
|
|
}
|
2013-08-01 08:52:51 +00:00
|
|
|
|
|
|
|
return array($doc, $allowed_elements, $disallowed_attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
function api_version() {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2020-09-22 06:04:33 +00:00
|
|
|
}
|