summaryrefslogtreecommitdiff
path: root/classes/sanitizer.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-08 16:14:48 +0300
committerAndrew Dolgov <[email protected]>2021-02-08 16:14:48 +0300
commit3b52cea8110541e1e5d8cb06198c11a2ed074b1c (patch)
tree763304f562f8787fa2e56291d032832981b5c436 /classes/sanitizer.php
parent1d5c8ee50082dd0221055969283b27f2b09b3bb4 (diff)
move some old-style handlers to new callback ones
Diffstat (limited to 'classes/sanitizer.php')
-rw-r--r--classes/sanitizer.php31
1 files changed, 14 insertions, 17 deletions
diff --git a/classes/sanitizer.php b/classes/sanitizer.php
index 5a054c3b0..2682471d0 100644
--- a/classes/sanitizer.php
+++ b/classes/sanitizer.php
@@ -41,14 +41,10 @@ class Sanitizer {
}
public static function iframe_whitelisted($entry) {
- @$src = parse_url($entry->getAttribute("src"), PHP_URL_HOST);
+ $src = parse_url($entry->getAttribute("src"), PHP_URL_HOST);
- if ($src) {
- foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) {
- if ($plugin->hook_iframe_whitelisted($src))
- return true;
- }
- }
+ if (!empty($src))
+ return PluginHost::getInstance()->run_hooks_until(PluginHost::HOOK_IFRAME_WHITELISTED, true, $src);
return false;
}
@@ -153,16 +149,17 @@ class Sanitizer {
$disallowed_attributes = array('id', 'style', 'class', 'width', 'height', 'allow');
- foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) {
- $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id);
- if (is_array($retval)) {
- $doc = $retval[0];
- $allowed_elements = $retval[1];
- $disallowed_attributes = $retval[2];
- } else {
- $doc = $retval;
- }
- }
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SANITIZE,
+ function ($result) use (&$doc, &$allowed_elements, &$disallowed_attributes) {
+ if (is_array($result)) {
+ $doc = $result[0];
+ $allowed_elements = $result[1];
+ $disallowed_attributes = $result[2];
+ } else {
+ $doc = $result;
+ }
+ },
+ $doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id);
$doc->removeChild($doc->firstChild); //remove doctype
$doc = self::strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes);