我如何在HTMLPurifier中允许"class"?我试图净化这个:
<div class="txt_r" id="test">Blah</div>
Run Code Online (Sandbox Code Playgroud)
我得到:
<div id="test">Blah</div>
Run Code Online (Sandbox Code Playgroud)
为什么上课消失了?我正在使用下一个配置:
$config->set('Attr.EnableID', true);
$config->set('CSS.Trusted', true);
$config->set('HTML.AllowedAttributes', 'style, src, class');
Run Code Online (Sandbox Code Playgroud)
pin*_*hic 14
您的问题可能HTML.AllowedAttributes实际上并不是那样.:)来自文档:
对于全局属性(style,id,class,dir,lang,xml:lang),语法为"tag.attr"或"*.attr".
你可能想要的是......
$config->set('HTML.AllowedAttributes', 'img.src,*.style,*.class');
Run Code Online (Sandbox Code Playgroud)
你也不应该单独使用HTML.AllowedAttributes,而是与HTML.AllowedElements:
$config->set('HTML.AllowedElements', 'img,div');
Run Code Online (Sandbox Code Playgroud)
或者,既不 使用HTML.AllowedAttributes 也不 HTML.AllowedElements使用HTML.Allowed.这看起来像这样:
$config->set('HTML.Allowed', 'div, *[style|class], img[src]');
Run Code Online (Sandbox Code Playgroud)