assertPurification("Null byte\0", "Null byte"); } function testStrict() { $this->config->set('HTML', 'Strict', true); $this->assertPurification( 'Illegal underline', 'Illegal underline' ); $this->assertPurification( '
Illegal contents', '
' ); } function testDifferentAllowedElements() { $this->config->set('HTML', 'AllowedElements', array('b', 'i', 'p', 'a')); $this->config->set('HTML', 'AllowedAttributes', array('a.href', '*.id')); $this->assertPurification( 'Illegal contents
Par.
Paragraph
TextBold' ); $this->assertPurification( 'Not allowedFoobar', 'Not allowedFoobar' // no ID!!! ); } function testDisableURI() { $this->config->set('URI', 'Disable', true); $this->assertPurification( '
');
}
function testScript() {
$this->config->set('HTML', 'Trusted', true);
$ideal = '';
$this->assertPurification($ideal);
$this->assertPurification(
'',
$ideal
);
$this->assertPurification(
'',
$ideal
);
$this->assertPurification(
'',
$ideal
);
$this->assertPurification(
'',
$ideal
);
}
function testGetInstance() {
$purifier =& HTMLPurifier::getInstance();
$purifier2 =& HTMLPurifier::getInstance();
$this->assertReference($purifier, $purifier2);
}
function testMakeAbsolute() {
$this->config->set('URI', 'Base', 'http://example.com/bar/baz.php');
$this->config->set('URI', 'MakeAbsolute', true);
$this->assertPurification(
'Foobar',
'Foobar'
);
}
function test_shiftJis() {
if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'Shift_JIS');
$this->config->set('Core', 'EscapeNonASCIICharacters', true);
$this->assertPurification(
"111"
);
}
function test_shiftJisWorstCase() {
if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'Shift_JIS');
$this->assertPurification( // Notice how Yen disappears
"111",
"111"
);
}
}