Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/roundcube/roundcubemail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2018-04-21 14:14:42 +0300
committerAleksander Machniak <alec@alec.pl>2018-04-21 14:14:42 +0300
commit63d3ad11fb216517495f75b536abc570bf1efa0a (patch)
treeef1e0385e18a76c35f86b7db500150efa7f9fac8 /tests
parent2f7aaca342ee972123fb75f5f6e74f28430a9b94 (diff)
Use Masterminds/HTML5 parser for HTML5 support (#5761)
Diffstat (limited to 'tests')
-rw-r--r--tests/Framework/Washtml.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index 7a6017644..ed523d23a 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -7,6 +7,14 @@
*/
class Framework_Washtml extends PHPUnit_Framework_TestCase
{
+ /**
+ * A helper method to remove comments added by rcube_washtml
+ */
+ function cleanupResult($html)
+ {
+ return preg_replace('/<!-- [a-z]+ (ignored|not allowed) -->/', '', $html);
+ }
+
/**
* Test the elimination of some XSS vulnerabilities
@@ -67,24 +75,24 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$washer = new rcube_washtml;
$html = "<!--[if gte mso 10]><p>p1</p><!--><p>p2</p>";
- $washed = $washer->wash($html);
+ $washed = $this->cleanupResult($washer->wash($html));
- $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>p2</p>', $washed, "HTML conditional comments (#1489004)");
+ $this->assertEquals('<p>p2</p>', $washed, "HTML conditional comments (#1489004)");
$html = "<!--TestCommentInvalid><p>test</p>";
- $washed = $washer->wash($html);
+ $washed = $this->cleanupResult($washer->wash($html));
- $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>test</p>', $washed, "HTML invalid comments (#1487759)");
+ $this->assertEquals('<p>test</p>', $washed, "HTML invalid comments (#1487759)");
$html = "<p>para1</p><!-- comment --><p>para2</p>";
- $washed = $washer->wash($html);
+ $washed = $this->cleanupResult($washer->wash($html));
- $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>para1</p><p>para2</p>', $washed, "HTML comments - simple comment");
+ $this->assertEquals('<p>para1</p><p>para2</p>', $washed, "HTML comments - simple comment");
$html = "<p>para1</p><!-- <hr> comment --><p>para2</p>";
- $washed = $washer->wash($html);
+ $washed = $this->cleanupResult($washer->wash($html));
- $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>para1</p><p>para2</p>', $washed, "HTML comments - tags inside (#1489904)");
+ $this->assertEquals('<p>para1</p><p>para2</p>', $washed, "HTML comments - tags inside (#1489904)");
}
/**
@@ -295,7 +303,7 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
function test_wash_mathml()
{
$mathml = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>
- <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics>
+ <math><semantics>
<mrow>
<msub><mi>I</mi><mi>D</mi></msub>
<mo>=</mo>
@@ -312,7 +320,7 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
</body></html>';
$exp = '<!-- html ignored --><!-- head ignored --><!-- meta ignored --><!-- body ignored -->
- <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics>
+ <math><semantics>
<mrow>
<msub><mi>I</mi><mi>D</mi></msub>
<mo>=</mo>