From 04994005e7f83a9ae48bd177b898dd17f7aa8e24 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 13 Jan 2015 03:44:20 -0500
Subject: [PATCH] Fix XSS issue in style attribute handling (#1490227)
---
tests/Framework/Washtml.php | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index f041504..e4e3de4 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -159,7 +159,7 @@
$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: \"新細明體\",\"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>";
@@ -183,4 +183,26 @@
$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: '"/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:'"/onerror=alert(1)//'>";
+ $exp = "<img style=\"aaa: '"/onerror=alert(1)//'\" />";
+
+ $washer = new rcube_washtml;
+ $washed = $washer->wash($html);
+
+ $this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
+ }
}
--
Gitblit v1.9.1