summaryrefslogtreecommitdiff
path: root/tests/Framework/Washtml.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2015-01-13 09:41:41 +0100
committerAleksander Machniak <alec@alec.pl>2015-01-13 09:41:41 +0100
commit786aa0725e28976bed5037814e01c44c90a551f5 (patch)
tree32b9da3074dbced5f29f57f378858d1a60afb458 /tests/Framework/Washtml.php
parentd204814a39509a9709f9e4cb60ef52ff501d530d (diff)
Fix XSS issue in style attribute handling (#1490227)
Diffstat (limited to 'tests/Framework/Washtml.php')
-rw-r--r--tests/Framework/Washtml.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index f041504d7..e4e3de41f 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -159,7 +159,7 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$washer = new rcube_washtml;
$washed = $washer->wash($html);
- $this->assertRegExp('|style=\'font-family: "新細明體","serif"; color: red\'|', $washed, "Unicode chars in style attribute - quoted (#1489697)");
+ $this->assertRegExp('|style="font-family: \&quot;新細明體\&quot;,\&quot;serif\&quot;; 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>";
@@ -183,4 +183,26 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$this->assertRegExp('|line-height: 1;|', $washed, "Untouched line-height (#1489917)");
$this->assertRegExp('|; height: 10px|', $washed, "Fixed height units");
}
+
+ /**
+ * Test invalid style cleanup - XSS prevention (#1490227)
+ */
+ function test_style_wash_xss()
+ {
+ $html = "<img style=aaa:'\"/onerror=alert(1)//'>";
+ $exp = "<img style=\"aaa: '&quot;/onerror=alert(1)//'\" />";
+
+ $washer = new rcube_washtml;
+ $washed = $washer->wash($html);
+
+ $this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
+
+ $html = "<img style=aaa:'&quot;/onerror=alert(1)//'>";
+ $exp = "<img style=\"aaa: '&quot;/onerror=alert(1)//'\" />";
+
+ $washer = new rcube_washtml;
+ $washed = $washer->wash($html);
+
+ $this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
+ }
}