purifier = new HTMLPurifier(); } function assertPurification($input, $expect = null) { if ($expect === null) $expect = $input; $result = $this->purifier->purify($input); $this->assertIdentical($expect, $result); } function testNull() { $this->assertPurification("Null byte\0", "Null byte"); } function testStrict() { $config = HTMLPurifier_Config::createDefault(); $config->set('HTML', 'Strict', true); $this->purifier = new HTMLPurifier( $config ); // verbose syntax $this->assertPurification( 'Illegal underline', 'Illegal underline' ); $this->assertPurification( '
Illegal contents
', '

Illegal contents

' ); } function testDifferentAllowedElements() { $this->purifier = new HTMLPurifier(array( 'HTML.AllowedElements' => array('b', 'i', 'p', 'a'), 'HTML.AllowedAttributes' => array('a.href', '*.id') )); $this->assertPurification( '

Par.

Paragraph

TextBold' ); $this->assertPurification( 'Not allowedFoobar', 'Not allowedFoobar' // no ID!!! ); } function testDisableURI() { $this->purifier = new HTMLPurifier( array('Attr.DisableURI' => true) ); $this->assertPurification( '', '' ); } function test_purifyArray() { $this->purifier = new HTMLPurifier(); $this->assertEqual( $this->purifier->purifyArray( array('Good', 'Sketchy', 'foo' => '') ), array('Good', 'Sketchy', 'foo' => 'bad') ); $this->assertIsA($this->purifier->context, 'array'); } function testEnableAttrID() { $this->purifier = new HTMLPurifier(); $this->assertPurification( 'foobar', 'foobar' ); $this->purifier = new HTMLPurifier(array('HTML.EnableAttrID' => true)); $this->assertPurification('foobar'); } } ?>