From cd60294ada5245c5835baebf0dbb3f44ee851317 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 31 Aug 2014 11:23:18 +0100 Subject: [PATCH] Fix rgb in border attribute with spaces, fixes #30. Signed-off-by: Edward Z. Yang --- NEWS | 2 ++ library/HTMLPurifier/AttrDef/CSS/Multiple.php | 2 +- tests/HTMLPurifier/AttrDef/CSSTest.php | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b4abb857..0b4eeea6 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Don't truncate upon encountering when using DOMLex. Thanks Myrto Christina for finally convincing me to fix this. - Update YouTube filter for new code. +- Fix parsing of rgb() values with spaces in them for 'border' + attribute. 4.6.0, released 2013-11-30 # Secure URI munge hashing algorithm has changed to hash_hmac("sha256", $url, $secret). diff --git a/library/HTMLPurifier/AttrDef/CSS/Multiple.php b/library/HTMLPurifier/AttrDef/CSS/Multiple.php index 9f266cdd..e707f871 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Multiple.php +++ b/library/HTMLPurifier/AttrDef/CSS/Multiple.php @@ -44,7 +44,7 @@ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef */ public function validate($string, $config, $context) { - $string = $this->parseCDATA($string); + $string = $this->mungeRgb($this->parseCDATA($string)); if ($string === '') { return false; } diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index 37ec2d4c..778a22bd 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -83,6 +83,8 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness $this->assertDef('background-position:left 90%;'); $this->assertDef('border-spacing:1em;'); $this->assertDef('border-spacing:1em 2em;'); + $this->assertDef('border-color: rgb(0, 0, 0) rgb(10,0,10)', 'border-color:rgb(0,0,0) rgb(10,0,10);'); + $this->assertDef('border: rgb(0, 0, 0)', 'border:rgb(0,0,0);'); // duplicates $this->assertDef('text-align:right;text-align:left;', -- 2.11.4.GIT