Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htmlpurifier remove inline css

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?

like image 285
applechief Avatar asked Jan 16 '12 14:01

applechief


1 Answers

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

like image 61
nulltoken Avatar answered Oct 22 '22 16:10

nulltoken