我想让用户使用标签<vid>Link</vid>,所以我在purifier的配置中添加了"vid“到HTML.AllowedElements中,所以它抛给我一个错误,告诉我它不知道这样的标签,并将我指向http://htmlpurifier.org/docs/enduser-customize.html,所以我尝试使用以下代码:
$config = $config->getHTMLDefinition(TRUE);
$config->addElement('vid', 'Block', 'Empty', 'Common', array());但是<vid>Link</vid>标签正在剥离。我哪里做错了?
发布于 2012-02-29 03:13:50
不要使用'Empty‘。此外,您的代码已过期。
<?php
include_once 'library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'test');
$config->set('HTML.DefinitionRev', 1);
if ($def = $config->maybeGetRawHTMLDefinition()) {
$def->addElement('vid', 'Block', 'Inline', 'Common', array());
}
$purifier = new HTMLPurifier($config);
echo $purifier->purify("<vid>Link</vid>\n");https://stackoverflow.com/questions/9486222
复制相似问题