0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +00:00

Fix bug with non-lower case color names in HTML.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2012-07-30 10:54:32 -04:00
parent d8bb73ce46
commit 72db575446
3 changed files with 4 additions and 1 deletions

1
NEWS
View File

@ -21,6 +21,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
- Fix bug with nofollow transform when pre-existing rel exists. - Fix bug with nofollow transform when pre-existing rel exists.
- Fix bug where background:url() always gets lower-cased - Fix bug where background:url() always gets lower-cased
(but not background-image:url()) (but not background-image:url())
- Fix bug with non lower-case color names in HTML
4.4.0, released 2012-01-18 4.4.0, released 2012-01-18
# Removed PEARSax3 handler. # Removed PEARSax3 handler.

View File

@ -14,7 +14,8 @@ class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef
$string = trim($string); $string = trim($string);
if (empty($string)) return false; if (empty($string)) return false;
if (isset($colors[strtolower($string)])) return $colors[$string]; $lower = strtolower($string);
if (isset($colors[$lower])) return $colors[$lower];
if ($string[0] === '#') $hex = substr($string, 1); if ($string[0] === '#') $hex = substr($string, 1);
else $hex = $string; else $hex = $string;

View File

@ -9,6 +9,7 @@ class HTMLPurifier_AttrDef_HTML_ColorTest extends HTMLPurifier_AttrDefHarness
$this->assertDef('foo', false); $this->assertDef('foo', false);
$this->assertDef('43', false); $this->assertDef('43', false);
$this->assertDef('red', '#FF0000'); $this->assertDef('red', '#FF0000');
$this->assertDef('RED', '#FF0000');
$this->assertDef('#FF0000'); $this->assertDef('#FF0000');
$this->assertDef('#453443'); $this->assertDef('#453443');
$this->assertDef('453443', '#453443'); $this->assertDef('453443', '#453443');