one tab preserved empty line above'; $this->assertEquals($htmlbr, purify_html($htmlbr)); // HTML5 is not supported by HTMLPurifier yet, test our own configuration $html5elements = '
section
mainhubzilla.org
'; $this->assertEquals($html5elements, purify_html($html5elements)); $this->assertEquals('', purify_html('')); // unsupported HTML5 elements $this->assertEquals('Your HTML parser does not support HTML5 video.', purify_html('')); $this->assertEquals('Your HTML parser does not support HTML5 audio.', purify_html('')); // preserve f6 and bootstrap additional data attributes from our own configuration $this->assertEquals('
text
', purify_html('
text
')); $this->assertEquals('', purify_html('')); $this->assertEquals('', purify_html('')); } /** * @covers ::purify_html */ public function testPurifyHTML_html() { $this->assertEquals('

ids und classes

', purify_html('

ids und classes

')); $this->assertEquals('

close missing tags

', purify_html('

close missing tags')); $this->assertEquals('

deprecated tag
', purify_html('
deprecated tag
')); $this->assertEquals('
illegal nesting
', purify_html('
illegal nesting
')); $this->assertEquals('link with target', purify_html('link with target')); $this->assertEquals('link with rel="nofollow"', purify_html('link with rel="nofollow"')); $this->assertEquals('a b', purify_html('a b')); $this->assertEquals('ä ä € €', purify_html('ä ä € €')); $this->assertEquals('text', purify_html('text')); $this->assertEquals('', purify_html('')); } /** * @covers ::purify_html */ public function testPurifyHTML_js() { $this->assertEquals('
', purify_html('
')); $this->assertEquals('link', purify_html('link')); $this->assertEquals('', purify_html('')); $this->assertEquals('', purify_html('')); } /** * @covers ::purify_html */ public function testPurifyHTML_css() { $this->assertEquals('

red

', purify_html('

red

')); $this->assertEquals('

invalid color

', purify_html('

invalid color

')); $this->assertEquals('

invalid style

', purify_html('

invalid style

')); // test our own CSS configuration $this->assertEquals('
position removed
', purify_html('
position removed
')); $this->assertEquals('
position preserved
', purify_html('
position preserved
', true)); $this->assertEquals('
invalid position removed
', purify_html('
invalid position removed
', true)); $this->assertEquals('
position removed
', purify_html('
position removed
')); $this->assertEquals('
position preserved
', purify_html('
position preserved
', true)); $this->assertEquals('
invalid position removed
', purify_html('
invalid position removed
', true)); } /** * @dataProvider notagsProvider */ public function testNotags($string, $expected) { $this->assertEquals($expected, notags($string)); } public function notagsProvider() { return [ 'empty string' => ['', ''], 'simple tag' => ['', '[value]'], 'tag pair' => ['text', '[b]text[/b]'], 'double angle bracket' => ['< ['>', '>'] ]; } /** * @dataProvider sanitise_aclProvider */ public function testSanitise_acl($string, $expected) { sanitise_acl($string); $this->assertEquals($expected, $string); } public function sanitise_aclProvider() { return [ 'text' => ['value', ''], 'text with angle bracket' => ['', '<[value]>'], 'comma separated acls' => ['value1,value2', ''] ]; } public function testUnsetSanitise_acl() { $empty = ''; sanitise_acl($empty); $this->assertTrue(isset($empty)); // unset() not working? Would expect false $this->assertEmpty($empty); } }