htmlpurifier remove inline css

2020-07-06 05:41发布

I am using htmlpurifier to clean up user content. I am trying to remove inline style attributes like

<div style="float:left">some text</div>

I want to remove the whole style attribute.

How to do it using htmlpurifier?

1条回答
▲ chillily
2楼-- · 2020-07-06 06:24

You can tweak the AllowedProperties configuration by passing it an array of valid css attributes that should not be removed (white-list approach).

However, the following should remove all css attributes

$config->set('CSS.AllowedProperties', array());

See this online demo of purifying your input html

查看更多
登录 后发表回答