diff options
| author | Andy Wermke <andy@dev.next-step-software.com> | 2013-04-04 16:10:23 +0200 |
|---|---|---|
| committer | Andy Wermke <andy@dev.next-step-software.com> | 2013-04-04 16:10:23 +0200 |
| commit | 92cd7f34b07e86062f2c024039e3309768b48ce6 (patch) | |
| tree | 63b9f39280ebcab80742d9f2b4db6a139c1791e1 /tests/Framework/Washtml.php | |
| parent | 029d18f13bcf01aa2f1f08dbdfc6400c081bf7cb (diff) | |
| parent | 443b92a7ee19e321b350750240e0fc54ec5be357 (diff) | |
Merge branch 'master' of https://github.com/roundcube/roundcubemail
Diffstat (limited to 'tests/Framework/Washtml.php')
| -rw-r--r-- | tests/Framework/Washtml.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php new file mode 100644 index 000000000..cd443266f --- /dev/null +++ b/tests/Framework/Washtml.php @@ -0,0 +1,58 @@ +<?php + +/** + * Test class to test rcube_washtml class + * + * @package Tests + */ +class Framework_Washtml extends PHPUnit_Framework_TestCase +{ + + /** + * Test the elimination of some XSS vulnerabilities + */ + function test_html_xss3() + { + // #1488850 + $html = '<p><a href="data:text/html,<script>alert(document.cookie)</script>">Firefox</a>' + .'<a href="vbscript:alert(document.cookie)">Internet Explorer</a></p>'; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertNotRegExp('/data:text/', $washed, "Remove data:text/html links"); + $this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links"); + } + + /** + * Test fixing of invalid href (#1488940) + */ + function test_href() + { + $html = "<p><a href=\"\nhttp://test.com\n\">Firefox</a>"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)"); + } + + /** + * Test handling HTML comments + */ + function test_comments() + { + $washer = new rcube_washtml; + + $html = "<!--[if gte mso 10]><p>p1</p><!--><p>p2</p>"; + $washed = $washer->wash($html); + + $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>p2</p>', $washed, "HTML conditional comments (#1489004)"); + + $html = "<!--TestCommentInvalid><p>test</p>"; + $washed = $washer->wash($html); + + $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>test</p>', $washed, "HTML invalid comments (#1487759)"); + } + +} |
