I’m using HTMLPurifier to sanitize HTML, but I want to prevent any changes to the inline style attribute. Specifically, I don’t want HTMLPurifier to modify or sanitize the values of the style attribute while purifying the HTML.
Here’s a sample code:
require_once 'ezyang/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$dirty_html = '<div style="background-color: rgb(240, 240, 240);"> How configure HTMLPurifier to prevent sanitize of Inline-style Attribute ? </div>';
// I want to prevent any change done by purify on style Attribute values
$clean_html = $purifier->purify($dirty_html);
// But in $clean_html div style value becomes: style="background-color:rgb(0,240,240);"
echo $clean_html;
How can I configure HTMLPurifier to skip sanitizing the style attribute ?