HtmlPurifier和预标签内容

问题描述 投票:4回答:2

有谁知道我应该如何配置HtmlPurifier来忽略<pre>标签内的内容?目前我有这样的事情:

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);
$def = $config->getHTMLDefinition(true);
$def->addAttribute('a', 'href*', 'URI');
$def->addAttribute('a', 'rel', 'CDATA');
$objPurifier = new HTMLPurifier($config);
return $objPurifier->purify($string);
htmlpurifier
2个回答
1
投票

0
投票

我解决了加入

pre[class]

到酒店

HTML.Allowed 
© www.soinside.com 2019 - 2024. All rights reserved.