【问题标题】:Allow only specific classes within the class attribute in HTML purifier仅允许 HTML 净化器中的类属性中的特定类
【发布时间】:2011-04-06 00:26:20
【问题描述】:

我知道我可以在HTML Purifier 中设置允许的标签和最终属性,例如:

$cfg->set('HTML.Allowed', 'a[href|title],'b','em','i','strike');

但是我怎样才能禁止任何与某些预定义值不匹配的属性值?

例如我可能想允许 div + class 标签:

$cfg->set('HTML.Allowed', 'div[class],a[href|title],'b','em','i','strike');

但仅当类是 abc、def 或 xyz 时

【问题讨论】:

    标签: php html htmlpurifier


    【解决方案1】:

    设置Attr.AllowedClasses。仅限制您希望允许的类。

    【讨论】:

    • 谢谢,这看起来会为所有元素全局设置允许的类。我不能允许<DIV> 使用某些类,而<p> 不能使用不同的类,对吧?
    • 手册中的@Rebecca 看起来你不能更具体。
    猜你喜欢
    • 2012-01-13
    • 1970-01-01
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    相关资源
    最近更新 更多