diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2012-12-26 18:49:06 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2012-12-26 18:49:06 +0100 |
commit | c942e4a2e9a97743850b4178ea66b3b33956e7f7 (patch) | |
tree | 8fda2746e6cd6e69fc74427c297f3113665fce00 /tests | |
parent | aabeab1e4e08ffba5d709aa71de1182dfeb698d1 (diff) | |
parent | 23b30e0afca5f9c31e05204c3a6ff3332791d3a1 (diff) |
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Framework/Html2text.php (renamed from tests/HtmlToText.php) | 6 | ||||
-rw-r--r-- | tests/Framework/StringReplacer.php | 6 | ||||
-rw-r--r-- | tests/Framework/Washtml.php | 28 | ||||
-rw-r--r-- | tests/MailFunc.php | 2 | ||||
-rw-r--r-- | tests/phpunit.xml | 3 |
5 files changed, 40 insertions, 5 deletions
diff --git a/tests/HtmlToText.php b/tests/Framework/Html2text.php index b90c61adf..1d8963878 100644 --- a/tests/HtmlToText.php +++ b/tests/Framework/Html2text.php @@ -1,11 +1,11 @@ <?php /** - * Test class to test html2text class + * Test class to test rcube_html2text class * * @package Tests */ -class HtmlToText extends PHPUnit_Framework_TestCase +class rc_html2text extends PHPUnit_Framework_TestCase { function data_html2text() @@ -49,7 +49,7 @@ class HtmlToText extends PHPUnit_Framework_TestCase */ function test_html2text($title, $in, $out) { - $ht = new html2text(null, false, false); + $ht = new rcube_html2text(null, false, false); $ht->set_html($in); $res = $ht->get_text(); diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php index a76ba00ee..60399cf6b 100644 --- a/tests/Framework/StringReplacer.php +++ b/tests/Framework/StringReplacer.php @@ -29,6 +29,12 @@ class Framework_StringReplacer extends PHPUnit_Framework_TestCase array('Start http://localhost/?foo End', 'Start <a href="http://localhost/?foo" target="_blank">http://localhost/?foo</a> End'), array('www.domain.tld', '<a href="http://www.domain.tld" target="_blank">www.domain.tld</a>'), array('WWW.DOMAIN.TLD', '<a href="http://WWW.DOMAIN.TLD" target="_blank">WWW.DOMAIN.TLD</a>'), + array('[http://link.com]', '[<a href="http://link.com" target="_blank">http://link.com</a>]'), + array('http://link.com?a[]=1', '<a href="http://link.com?a[]=1" target="_blank">http://link.com?a[]=1</a>'), + array('http://link.com?a[]', '<a href="http://link.com?a[]" target="_blank">http://link.com?a[]</a>'), + array('(http://link.com)', '(<a href="http://link.com" target="_blank">http://link.com</a>)'), + array('http://link.com?a(b)c', '<a href="http://link.com?a(b)c" target="_blank">http://link.com?a(b)c</a>'), + array('http://link.com?(link)', '<a href="http://link.com?(link)" target="_blank">http://link.com?(link)</a>'), ); } diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php new file mode 100644 index 000000000..088ac4a8c --- /dev/null +++ b/tests/Framework/Washtml.php @@ -0,0 +1,28 @@ +<?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"); + } + +} diff --git a/tests/MailFunc.php b/tests/MailFunc.php index 4d4250c22..38c0bac30 100644 --- a/tests/MailFunc.php +++ b/tests/MailFunc.php @@ -173,7 +173,7 @@ class MailFunc extends PHPUnit_Framework_TestCase function test_resolve_base() { $html = file_get_contents(TESTS_DIR . 'src/htmlbase.txt'); - $html = rcmail_resolve_base($html); + $html = rcube_washtml::resolve_base($html); $this->assertRegExp('|src="http://alec\.pl/dir/img1\.gif"|', $html, "URI base resolving [1]"); $this->assertRegExp('|src="http://alec\.pl/dir/img2\.gif"|', $html, "URI base resolving [2]"); diff --git a/tests/phpunit.xml b/tests/phpunit.xml index c9e229e97..5a858111b 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -12,6 +12,7 @@ <file>Framework/Csv2vcard.php</file> <file>Framework/Enriched.php</file> <file>Framework/Html.php</file> + <file>Framework/Html2text.php</file> <file>Framework/Imap.php</file> <file>Framework/ImapGeneric.php</file> <file>Framework/Image.php</file> @@ -28,7 +29,7 @@ <file>Framework/User.php</file> <file>Framework/Utils.php</file> <file>Framework/VCard.php</file> - <file>HtmlToText.php</file> + <file>Framework/Washtml.php</file> <file>MailFunc.php</file> </testsuite> <testsuite name="Managesieve Tests"> |