diff --git a/NEWS b/NEWS index 11b3936a..88793641 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier 2.1.4, unknown release date ! DefinitionCacheFactory now can register new implementations +! CSS properties are now case-insensitive - Colors missing # but in hex form will be corrected - CSS Number algorithm improved diff --git a/library/HTMLPurifier/AttrDef/CSS.php b/library/HTMLPurifier/AttrDef/CSS.php index d0f49bc4..71523be1 100644 --- a/library/HTMLPurifier/AttrDef/CSS.php +++ b/library/HTMLPurifier/AttrDef/CSS.php @@ -38,7 +38,20 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef list($property, $value) = explode(':', $declaration, 2); $property = trim($property); $value = trim($value); - if (!isset($definition->info[$property])) continue; + $ok = false; + do { + if (isset($definition->info[$property])) { + $ok = true; + break; + } + if (ctype_lower($property)) break; + $property = strtolower($property); + if (isset($definition->info[$property])) { + $ok = true; + break; + } + } while(0); + if (!$ok) continue; // inefficient call, since the validator will do this again if (strtolower(trim($value)) !== 'inherit') { // inherit works for everything (but only on the base property) diff --git a/tests/HTMLPurifier/AttrDef/CSSTest.php b/tests/HTMLPurifier/AttrDef/CSSTest.php index 994fad12..59d86e2e 100644 --- a/tests/HTMLPurifier/AttrDef/CSSTest.php +++ b/tests/HTMLPurifier/AttrDef/CSSTest.php @@ -107,6 +107,9 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness $this->assertDef(' font-weight : bold; color : #ff0000', 'font-weight:bold;color:#ff0000;'); + // case-insensitivity + $this->assertDef('FLOAT:LEFT;', 'float:left;'); + } }