I’d like to use the CHtmlPurifier
to strip html tags. But I don’t want it to escape the “<” character because I later use CHtml::encode()
on the text in the view so it would be escaped twice.
This is my unit test:
<?php
class CHtmlPurifierTest extends CTestCase
{
public function testCHtmlPurifier()
{
$p = new CHtmlPurifier();
$p->options = array(
'HTML'=>array('Allowed' => '',), // don't allow any HTML
'Filter.ExtractStyleBlocks.Escaping'=>false, // Whether or not to escape the dangerous characters <, > and & as \3C, \3E and \26, respectively.
);
$this->assertEquals('Do my Job if <£10', $p->purify('Do my Job if <£10'));
}
}
The test fails because "<" is converted into "<":
1) CHtmlPurifierTest::testCHtmlPurifier
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1<2'
+'1<2'
Does anyone know the HTMLPurifier incanation to disable escaping? because
'Filter.ExtractStyleBlocks.Escaping'=>false
obviously doesn’t work