Skip to content

Commit

Permalink
Fix bug with non-lower case color names in HTML.
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Jul 30, 2012
1 parent d8bb73c commit 72db575
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
- Fix bug with nofollow transform when pre-existing rel exists.
- Fix bug where background:url() always gets lower-cased
(but not background-image:url())
- Fix bug with non lower-case color names in HTML

4.4.0, released 2012-01-18
# Removed PEARSax3 handler.
Expand Down
3 changes: 2 additions & 1 deletion library/HTMLPurifier/AttrDef/HTML/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function validate($string, $config, $context) {
$string = trim($string);

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);
else $hex = $string;

Expand Down
1 change: 1 addition & 0 deletions tests/HTMLPurifier/AttrDef/HTML/ColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function test() {
$this->assertDef('foo', false);
$this->assertDef('43', false);
$this->assertDef('red', '#FF0000');
$this->assertDef('RED', '#FF0000');
$this->assertDef('#FF0000');
$this->assertDef('#453443');
$this->assertDef('453443', '#453443');
Expand Down

0 comments on commit 72db575

Please sign in to comment.