How do I get an HTML cleaner to remove content from forbidden tags?

I am using this code to set up my HTML cleaner:

$config   = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'div,p,ol,ul,li,br'); // only allow these tags
$purifier = new \HTMLPurifier($config);

      

I found that while the HTMLPurifier strips tags like style

and table

, the content inside those tags is still included in the stripped output.

How can I get the HTML cleaner to not return content in tags that are not allowed?

EDIT:

I found the Core.HiddenElements setting that makes it seem like the content of the tag style

shouldn't appear in the output, but with my configuration, it does.

I tried adding the following to my code, but it didn't make any difference (the content of the tags style

is still showing):

$config->set('Core.HiddenElements', array (
    'script' => true,
    'style' => true,
    'table' => true
));

      

+3


source to share





All Articles