From bae26f1c1663215cd711cc1a207012b7d3f742ae Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 22 Oct 2022 10:11:36 +0800 Subject: [PATCH] fix(web): prevent warning from HTMLPurifier ref: http://htmlpurifier.org/docs/enduser-customize.html#optimized --- web/app/models/HTML.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/web/app/models/HTML.php b/web/app/models/HTML.php index ec35e14..a08f041 100644 --- a/web/app/models/HTML.php +++ b/web/app/models/HTML.php @@ -167,9 +167,6 @@ class HTML { public static function purifier() { $config = HTMLPurifier_Config::createDefault(); - // $config->set('Cache.DefinitionImpl', null); - $config->set('HTML.DefinitionID', 'UOJ__HTML::purifier()'); - $config->set('HTML.DefinitionRev', 1); $config->set('Output.Newline', true); $def = $config->getHTMLDefinition(true); @@ -209,12 +206,10 @@ class HTML { 'br' => [], 'span' => ['data-realname' => 'Text', 'data-uoj-username' => 'Number'], ]; - - $config = HTMLPurifier_Config::createDefault(); $allowed_elements = []; $allowed_attributes = []; - + foreach ($allowed_html as $element => $attributes) { $allowed_elements[$element] = true; foreach ($attributes as $attribute => $type) { @@ -222,12 +217,9 @@ class HTML { } } + $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.AllowedElements', $allowed_elements); $config->set('HTML.AllowedAttributes', $allowed_attributes); - - // $config->set('Cache.DefinitionImpl', null); - $config->set('HTML.DefinitionID', 'UOJ__HTML::purifier_inline()'); - $config->set('HTML.DefinitionRev', 1); $def = $config->getHTMLDefinition(true); foreach ($allowed_html as $element => $attributes) {