From 7ac94421bf85eb04c00c5ed05390e1ea0c6bcb0b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak
Date: Tue, 25 Dec 2012 18:06:17 +0100
Subject: Move washtml class into Roundcube Framework (rcube_washtml), add some
improvements
---
tests/Framework/Washtml.php | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 tests/Framework/Washtml.php
(limited to 'tests/Framework/Washtml.php')
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 @@
+Firefox'
+ .'Internet Explorer
';
+
+ $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");
+ }
+
+}
--
cgit v1.2.3
From 1f910cb50dcb12e84d92db4d61dcd8dbb0f0c5b6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak
Date: Fri, 1 Feb 2013 20:04:00 +0100
Subject: Fix handling link href attribute value with (valid) newline
characters (#1488940)
---
program/lib/Roundcube/rcube_washtml.php | 3 ++-
tests/Framework/Washtml.php | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
(limited to 'tests/Framework/Washtml.php')
diff --git a/program/lib/Roundcube/rcube_washtml.php b/program/lib/Roundcube/rcube_washtml.php
index 715c46047..2a261419f 100644
--- a/program/lib/Roundcube/rcube_washtml.php
+++ b/program/lib/Roundcube/rcube_washtml.php
@@ -240,7 +240,8 @@ class rcube_washtml
$value = $node->getAttribute($key);
if (isset($this->_html_attribs[$key]) ||
- ($key == 'href' && !preg_match('!^(javascript|vbscript|data:text)!i', $value)
+ ($key == 'href' && ($value = trim($value))
+ && !preg_match('!^(javascript|vbscript|data:text)!i', $value)
&& preg_match('!^([a-z][a-z0-9.+-]+:|//|#).+!i', $value))
) {
$t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index 088ac4a8c..6f4aa9783 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -25,4 +25,18 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links");
}
+ /**
+ * Test fixing of invalid href (#1488940)
+ */
+ function test_href()
+ {
+ $html = "Firefox";
+
+ $washer = new rcube_washtml;
+
+ $washed = $washer->wash($html);
+
+ $this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)");
+ }
+
}
--
cgit v1.2.3
From 1e2468e4b9e9fb44055757a5460df1a6bf31313b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak
Date: Fri, 22 Mar 2013 10:23:39 +0100
Subject: Added two tests for HTML comments handling in rcube_washtml class
---
tests/Framework/Washtml.php | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
(limited to 'tests/Framework/Washtml.php')
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index 6f4aa9783..cd443266f 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -18,7 +18,6 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
.'Internet Explorer
';
$washer = new rcube_washtml;
-
$washed = $washer->wash($html);
$this->assertNotRegExp('/data:text/', $washed, "Remove data:text/html links");
@@ -33,10 +32,27 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$html = "Firefox";
$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 = "
p2
";
+ $washed = $washer->wash($html);
+
+ $this->assertEquals('p2
', $washed, "HTML conditional comments (#1489004)");
+
+ $html = "test
', $washed, "HTML invalid comments (#1487759)");
+ }
+
}
--
cgit v1.2.3