From 2130fe7a18d7e1863575feda9ec39654541eee77 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 18 Mar 2013 22:26:36 +0400 Subject: add experimental HOOK_SANITIZE --- classes/pluginhost.php | 1 + 1 file changed, 1 insertion(+) (limited to 'classes/pluginhost.php') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 592629881..79544b01b 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -21,6 +21,7 @@ class PluginHost { const HOOK_RENDER_ARTICLE = 10; const HOOK_RENDER_ARTICLE_CDM = 11; const HOOK_FEED_FETCHED = 12; + const HOOK_SANITIZE = 13; const KIND_ALL = 1; const KIND_SYSTEM = 2; -- cgit v1.2.3-54-g00ecf From be124dc2361539455121fa29c77bf60a85014b13 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 00:00:13 +0400 Subject: Revert "add experimental HOOK_SANITIZE" This reverts commit 2130fe7a18d7e1863575feda9ec39654541eee77. --- classes/pluginhost.php | 1 - include/functions.php | 23 +++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) (limited to 'classes/pluginhost.php') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 79544b01b..592629881 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -21,7 +21,6 @@ class PluginHost { const HOOK_RENDER_ARTICLE = 10; const HOOK_RENDER_ARTICLE_CDM = 11; const HOOK_FEED_FETCHED = 12; - const HOOK_SANITIZE = 13; const KIND_ALL = 1; const KIND_SYSTEM = 2; diff --git a/include/functions.php b/include/functions.php index ae9561337..2120a96b9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2597,25 +2597,12 @@ //$node = $doc->getElementsByTagName('body')->item(0); + $doc->removeChild($doc->firstChild); //remove doctype + $res = $doc->saveHTML(); - $beforehooks = $res; - - global $pluginhost; - if ($pluginhost) { - foreach ($pluginhost->get_hooks($pluginhost::HOOK_SANITIZE) as $p) { - $res = $p->hook_sanitize($res); - } - } - - // nothing changed, use standard filters - if ($beforehooks == $res) { - $doc->removeChild($doc->firstChild); //remove doctype - $res = $doc->saveHTML(); - - $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1, 'balance' => 0); - $spec = 'img=width,height'; - $res = htmLawed($res, $config, $spec); - } + $config = array('safe' => 1, 'deny_attribute' => 'style, width, height, class, id', 'comment' => 1, 'cdata' => 1, 'balance' => 0); + $spec = 'img=width,height'; + $res = htmLawed($res, $config, $spec); return $res; } -- cgit v1.2.3-54-g00ecf From e9b86f0a1c6165f4f06b1f7909889abfea96b620 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 18:58:42 +0400 Subject: reimplement HOOK_SANITIZE (plugs before final removal of harmful tags) --- classes/pluginhost.php | 1 + include/functions.php | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'classes/pluginhost.php') diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 592629881..79544b01b 100644 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -21,6 +21,7 @@ class PluginHost { const HOOK_RENDER_ARTICLE = 10; const HOOK_RENDER_ARTICLE_CDM = 11; const HOOK_FEED_FETCHED = 12; + const HOOK_SANITIZE = 13; const KIND_ALL = 1; const KIND_SYSTEM = 2; diff --git a/include/functions.php b/include/functions.php index 3793e0426..d1743af7a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2615,6 +2615,14 @@ $entry->setAttribute('sandbox', true); } + global $pluginhost; + + if (isset($pluginhost)) { + foreach ($pluginhost->get_hooks($pluginhost::HOOK_SANITIZE) as $plugin) { + $doc = $plugin->hook_sanitize($doc, $site_url); + } + } + $doc->removeChild($doc->firstChild); //remove doctype $doc = strip_harmful_tags($doc); $res = $doc->saveHTML(); -- cgit v1.2.3-54-g00ecf