我在我的系统中使用 HTMLPurifier 并且由于某种原因它转换如下:
<div class="item-horizontal mrb14" id="traditional">
<a href="/" title="Traditional">
<h3>Traditional</h3>
</a>
</div>
变成这样的东西:
<div class="item-horizontal mrb14" id="anchor-traditional">
<a href="/" title="Traditional"></a>
<h3><a href="/" title="Traditional">Traditional</a></h3>
<a href="/" title="Traditional"></a>
</div>
知道我应该在配置中添加什么吗?- 我目前的设置是:
require_once('HTMLPurifier.auto.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$config->set('Attr.AllowedFrameTargets', array('_blank'));
$config->set('HTML.Trusted', true);
$config->set('HTML.SafeObject', true);
$config->set('Output.FlashCompat', true);
$config->set('Filter.Custom', array( new HTMLPurifier_Filter_SafeIframe() ));
$config->set('Attr.EnableID', true);
$config->set('Attr.IDPrefix', 'anchor-');
$def = $config->getHTMLDefinition(true);
$def->addAttribute('a', 'href*', 'URI');
$def->addAttribute('a', 'rel', 'CDATA');
$objPurifier = new HTMLPurifier($config);
return $objPurifier->purify($string);