Skip to content

Commit

Permalink
Added two tests for HTML comments handling in rcube_washtml class
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Mar 22, 2013
1 parent da595a5 commit 71cae61
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/Framework/Washtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function test_html_xss3()
.'<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");
Expand All @@ -33,10 +32,27 @@ 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)");
}

}

0 comments on commit 71cae61

Please sign in to comment.