Search code examples
phphtmlcsshtmlpurifier

htmlpurifier does not allow css important decleration


I have the following div.

<div align="center" style="MARGIN-LEFT: 0pt  !important; DISPLAY: block  !important; MARGIN-RIGHT: 0pt  !important; TEXT-INDENT: 0pt  !important"><font style="FONT-SIZE: 10pt  !important; FONT-FAMILY: times new roman  !important; FONT-WEIGHT: bold  !important; DISPLAY: inline  !important">UNITED STATES<font style="FONT-FAMILY: times new roman  !important; DISPLAY: inline  !important">&nbsp;</font></font></div>

after cleaning with htmlpurifier, !important declarations are removed. How can htmlpurifier allow it?

my config:

$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.Trusted', 'HTML 4.01 Transitional'); 
$purifier = new HTMLPurifier($config);

Solution

  • You can use CSS.AllowImportant