/', '', $html); } /** * Test the elimination of some XSS vulnerabilities */ public function test_html_xss() { // #1488850 $html = 'Firefox' . 'Internet Explorer
' . 'Firefox' . 'Internet Explorer' . 'CLICK ME'; // #6896 $washer = new \rcube_washtml(); $washed = $washer->wash($html); $this->assertDoesNotMatchRegularExpression('/data:text/', $washed, 'Remove data:text/html links'); $this->assertDoesNotMatchRegularExpression('/vbscript:/', $washed, 'Remove vbscript: links'); $this->assertDoesNotMatchRegularExpression('/data:application/', $washed, 'Remove data:application links'); } /** * Test fixing of invalid href */ public function test_href() { $html = "FirefoxFirefox"; $washer = new \rcube_washtml(); $washed = $washer->wash($html); $this->assertMatchesRegularExpression('|href="http://test\.com"|', $washed, 'Link href with newlines (#1488940)'); $this->assertMatchesRegularExpression('|href="http://domain\.com"|', $washed, 'Link href with no protocol (#7454)'); } /** * Test data:image with newlines (#8613) */ public function test_data_image_with_newline() { $html = "
' . 'Internet Explorer
' . '' . '' . 'Internet Explorer
' . ''; $washer = new \rcube_washtml(); $washed = $washer->wash($html); $this->assertDoesNotMatchRegularExpression('/data:text/', $washed, 'data:text/html in area href'); $this->assertDoesNotMatchRegularExpression('/vbscript:/', $washed, 'vbscript: in area href'); $this->assertDoesNotMatchRegularExpression('/javascript:/', $washed, 'javascript: in area href'); } /** * Test removing of object tag, but keeping innocent children */ public function test_object() { $html = "/', $washed, 'Keep embedded tags'); } /** * Test handling HTML comments */ public function test_comments() { $washer = new \rcube_washtml(); $html = '
p2
'; $washed = $this->cleanupResult($washer->wash($html)); $this->assertSame('p2
', $washed, 'HTML conditional comments (#1489004)'); $html = 'para2
'; $washed = $this->cleanupResult($washer->wash($html)); $this->assertSame('para1
para2
', $washed, 'HTML comments - simple comment'); $html = 'para1
para2
'; $washed = $this->cleanupResult($washer->wash($html)); $this->assertSame('para1
para2
', $washed, 'HTML comments - tags inside (#1489904)'); $html = 'para1
para2
'; $washed = $this->cleanupResult($washer->wash($html)); $this->assertSame('para1
para2
', $washed, 'HTML comments - bracket inside'); $html = "\n2\n4
"; $washed = $this->cleanupResult($washer->wash($html)); $this->assertSame("\n2\n4
", $washed, 'HTML comments (#6464)'); } /** * Test fixing of invalid self-closing elements (#1489137) */ public function test_self_closing() { $html = '