From 0b36d151572e050b51d82e7429fee847ebb33e22 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Thu, 20 Nov 2014 06:03:22 -0500 Subject: [PATCH] Add method to display operation (uploading) progress in UI message --- tests/Framework/Washtml.php | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 102 insertions(+), 0 deletions(-) diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php index 0d050ff..f041504 100644 --- a/tests/Framework/Washtml.php +++ b/tests/Framework/Washtml.php @@ -53,6 +53,16 @@ $washed = $washer->wash($html); $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>test</p>', $washed, "HTML invalid comments (#1487759)"); + + $html = "<p>para1</p><!-- comment --><p>para2</p>"; + $washed = $washer->wash($html); + + $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>para1</p><!-- node type 8 --><p>para2</p>', $washed, "HTML comments - simple comment"); + + $html = "<p>para1</p><!-- <hr> comment --><p>para2</p>"; + $washed = $washer->wash($html); + + $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>para1</p><!-- node type 8 --><p>para2</p>', $washed, "HTML comments - tags inside (#1489904)"); } /** @@ -81,4 +91,96 @@ $this->assertRegExp('|</a>|', $washed, "Invalid closing tag (#1489446)"); } + /** + * Test fixing of invalid lists nesting (#1488768) + */ + function test_lists() + { + $data = array( + array( + "<ol><li>First</li><li>Second</li><ul><li>First sub</li></ul><li>Third</li></ol>", + "<ol><li>First</li><li>Second<ul><li>First sub</li></ul></li><li>Third</li></ol>" + ), + array( + "<ol><li>First<ul><li>First sub</li></ul></li></ol>", + "<ol><li>First<ul><li>First sub</li></ul></li></ol>", + ), + array( + "<ol><li>First<ol><li>First sub</li></ol></li></ol>", + "<ol><li>First<ol><li>First sub</li></ol></li></ol>", + ), + array( + "<ul><li>First</li><ul><li>First sub</li><ul><li>sub sub</li></ul></ul><li></li></ul>", + "<ul><li>First<ul><li>First sub<ul><li>sub sub</li></ul></li></ul></li><li></li></ul>", + ), + array( + "<ul><li>First</li><li>second</li><ul><ul><li>sub sub</li></ul></ul></ul>", + "<ul><li>First</li><li>second<ul><ul><li>sub sub</li></ul></ul></li></ul>", + ), + array( + "<ol><ol><ol></ol></ol></ol>", + "<ol><ol><ol></ol></ol></ol>", + ), + array( + "<div><ol><ol><ol></ol></ol></ol></div>", + "<div><ol><ol><ol></ol></ol></ol></div>", + ), + ); + + foreach ($data as $element) { + rcube_washtml::fix_broken_lists($element[0]); + + $this->assertSame($element[1], $element[0], "Broken nested lists (#1488768)"); + } + } + + /** + * Test color style handling (#1489697) + */ + function test_color_style() + { + $html = "<p style=\"font-size: 10px; color: rgb(241, 245, 218)\">a</p>"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|color: rgb\(241, 245, 218\)|', $washed, "Color style (#1489697)"); + $this->assertRegExp('|font-size: 10px|', $washed, "Font-size style"); + } + + /** + * Test handling of unicode chars in style (#1489777) + */ + function test_style_unicode() + { + $html = "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> + <body><span style='font-family:\"新細明體\",\"serif\";color:red'>test</span></body></html>"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|style=\'font-family: "新細明體","serif"; color: red\'|', $washed, "Unicode chars in style attribute - quoted (#1489697)"); + + $html = "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> + <body><span style='font-family:新細明體;color:red'>test</span></body></html>"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|style="font-family: 新細明體; color: red"|', $washed, "Unicode chars in style attribute (#1489697)"); + } + + /** + * Test style item fixes + */ + function test_style_wash() + { + $html = "<p style=\"line-height: 1; height: 10\">a</p>"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|line-height: 1;|', $washed, "Untouched line-height (#1489917)"); + $this->assertRegExp('|; height: 10px|', $washed, "Fixed height units"); + } } -- Gitblit v1.9.1