From a5b4ed2126a9a6002aafb5dc3a6c2f46ca30f954 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 4 Sep 2006 23:01:47 +0000 Subject: [PATCH] [1.0.1] Fixed rejection of inline style declarations that had lots of extra space in them. This manifested in TinyMCE. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@382 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 2 ++ library/HTMLPurifier/AttrDef/CSS.php | 2 ++ tests/HTMLPurifier/AttrDef/CSSTest.php | 4 ++++ tests/HTMLPurifier/Test.php | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7680373c..31c2b87b 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Fixed slight bug in DOMLex attribute parsing - Fixed rejection of case-insensitive configuration values when there is a set of allowed values. This manifested in %Core.Encoding. +- Fixed rejection of inline style declarations that had lots of extra + space in them. This manifested in TinyMCE. 1.0.0, released 2006-09-01 - Fixed broken numeric entity conversion diff --git a/library/HTMLPurifier/AttrDef/CSS.php b/library/HTMLPurifier/AttrDef/CSS.php index ce1b791c..1ba0e219 100644 --- a/library/HTMLPurifier/AttrDef/CSS.php +++ b/library/HTMLPurifier/AttrDef/CSS.php @@ -28,6 +28,8 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef if (!$declaration) continue; if (!strpos($declaration, ':')) continue; list($property, $value) = explode(':', $declaration, 2); + $property = trim($property); + $value = trim($value); if (!isset($definition->info[$property])) continue; // inefficient call, since the validator will do this again if (strtolower(trim($value)) !== 'inherit') { diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index ad4ce738..7afa2172 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -92,6 +92,10 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness $this->assertDef('position:absolute;', false); $this->assertDef('background-image:url(javascript:alert\(\));', false); + // airy input + $this->assertDef(' font-weight : bold; color : #ff0000', + 'font-weight:bold;color:#ff0000;'); + } } diff --git a/tests/HTMLPurifier/Test.php b/tests/HTMLPurifier/Test.php index a4860405..ccb7af43 100644 --- a/tests/HTMLPurifier/Test.php +++ b/tests/HTMLPurifier/Test.php @@ -8,7 +8,8 @@ class HTMLPurifier_Test extends UnitTestCase { var $purifier; - function assertPurification($input, $expect) { + function assertPurification($input, $expect = null) { + if ($expect === null) $expect = $input; $result = $this->purifier->purify($input); $this->assertIdentical($expect, $result); }