summaryrefslogtreecommitdiff
path: root/plugins/no_iframes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2014-11-25 18:40:19 +0300
committerAndrew Dolgov <[email protected]>2014-11-25 18:40:19 +0300
commite8a0d290c0622d8f1d008e92c4bc56fd701a8b68 (patch)
tree1a3a404dab42695788d64262daed51ee87849e95 /plugins/no_iframes
parent2c30a62e77688da34b7ce30832524e3a61af3508 (diff)
no_iframes: remove everything except good iframes
Diffstat (limited to 'plugins/no_iframes')
-rw-r--r--plugins/no_iframes/init.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/no_iframes/init.php b/plugins/no_iframes/init.php
index c66d7abaf..35f7187f5 100644
--- a/plugins/no_iframes/init.php
+++ b/plugins/no_iframes/init.php
@@ -4,7 +4,7 @@ class No_Iframes extends Plugin {
function about() {
return array(1.0,
- "Remove embedded iframes",
+ "Remove embedded iframes (unless whitelisted)",
"fox");
}
@@ -16,7 +16,13 @@ class No_Iframes extends Plugin {
function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
- $allowed_elements = array_diff($allowed_elements, array("iframe"));
+ $xpath = new DOMXpath($doc);
+ $entries = $xpath->query('//iframe');
+
+ foreach ($entries as $entry) {
+ if (!iframe_whitelisted($entry))
+ $entry->parentNode->removeChild($entry);
+ }
return array($doc, $allowed_elements, $disallowed_attributes);
}