It's not working as it should ?
Closed this issue · 3 comments
ivanradojevic-web-dev commented
$config = ['HTML.ForbiddenElements' => 'span[style]'];
$cleaned = Purify::clean($cleaned_content, $config);
return $cleaned;
//result <span style="font-weight:400;"> is still there
Restingo commented
@ivanradojevic-web-dev with this one it works:
$config = ['HTML.ForbiddenElements' => 'span[style]', 'CSS.AllowedProperties' => ''];
$cleaned_content = '<span style="font-weight:400;">';
$cleaned = Purify::clean($cleaned_content, $config);
return $cleaned;
=> "<span></span>"
mohammadsyuhada commented
For forbidden elements, i think we should only pass the element itself for it to work. like this:
$config = ['HTML.ForbiddenElements' => 'span'];
Example:
$content = '<span> Hello world </span>';
$cleaned = Purify::clean($content, $config);
//result Hello World
But if you would like to remove the style but keeping the span element, you should be using 'HTML.Allowed'.
$config = ['HTML.Allowed' => 'span'];
Example:
$content = '<span style="font-weight:400;> Hello world </span>';
$cleaned = Purify::clean($content, $config);
//result <span> Hello world </span>
stevebauman commented
Thanks for clarifying that @kotakSempit! 🙏
Closing due to inactivity from OP.