Php 允许使用htmlpurifier将自定义属性添加到元素
在我的小程序进行到一半时被卡住了,需要帮助完成最后一步 需要添加自定义元素以接受将通过textarea表单传递的自定义Php 允许使用htmlpurifier将自定义属性添加到元素,php,htmlpurifier,Php,Htmlpurifier,在我的小程序进行到一半时被卡住了,需要帮助完成最后一步 需要添加自定义元素以接受将通过textarea表单传递的自定义book元素 $dirty = 'you should check this out: <book author="me">my book title</book>!'; $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.Allowed', 'book'); $de
book
元素
$dirty = 'you should check this out: <book author="me">my book title</book>!';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'book');
$def = $config->getHTMLDefinition(true);
$def->addElement('book', 'Inline', 'Inline', 'Common');
$purifier = new HTMLPurifier($config);
echo $purifier->purify($dirty);
它返回错误:
不支持元素“book”中的属性“author”
我需要它,以便可以包括或不包括author=“me”
请有人分享代码更改/添加我需要获得允许的author=“me”
-谢谢
我正在运行htmlpurifier 4.6.0您是否尝试过使用
$def->addAttribute('book','author','CDATA')
在您的$def->addElement(…)
呼叫之后?文档是否不足?是的,否则我不会发布这个问题。
`$config->set('HTML.Allowed', 'book[author]');`