assertTrue(valid_email_regex('ken@spaz.org')); $this->assertTrue(valid_email_regex('ken@restivo.org')); $this->assertTrue(valid_email_regex('nobody@hubzilla.org')); $this->assertTrue(valid_email_regex('foo+nobody@hubzilla.org')); } /** * @covers ::valid_email_regex */ public function testBadEmail() { $this->assertFalse(valid_email_regex('nobody!uses!these!any.more')); $this->assertFalse(valid_email_regex('foo@bar@hubzilla.org')); } /** * @covers ::purify_html */ public function testPurifyHTML() { // linebreaks $htmlbr = 'first line
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)); } }