How can i allow “class” in HTMLPurifier? I am trying to purify this:
<div class="txt_r" id="test">Blah</div>
And i get:
<div id="test">Blah</div>
Why class is dissapeared? I am using next config:
$config->set('Attr.EnableID', true);
$config->set('CSS.Trusted', true);
$config->set('HTML.AllowedAttributes', 'style, src, class');
Your problem is probably that
HTML.AllowedAttributesdoesn’t actually work that way. 🙂 From the docs:What you probably want is…
You also shouldn’t use
HTML.AllowedAttributesby itself, but in tandem withHTML.AllowedElements:Alternatively, use neither
HTML.AllowedAttributesnorHTML.AllowedElementsand instead useHTML.Allowed. That would look something like this: