user398341
user398341

Reputation: 6587

HtmlPurifier and pre tag content

Does anyone know how should I configure HtmlPurifier to ignore content within <pre> tag? Currently I have something like this:

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);

Upvotes: 4

Views: 595

Answers (2)

Davide Casiraghi
Davide Casiraghi

Reputation: 18117

I solved adding

pre[class]

to the property

HTML.Allowed 

Upvotes: 0

Edward Z. Yang
Edward Z. Yang

Reputation: 26762

Try %Core.HiddenElements.

Upvotes: 1

Related Questions