From 6f71e656612413c4b2da25288196fdb808f9063a Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 17 Jun 2008 03:18:23 +0000 Subject: [PATCH] [2.1.5] [MFH] Fix text-decoration: none bug git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/php4@1800 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 1 + library/HTMLPurifier/AttrDef/CSS/TextDecoration.php | 5 ++++- tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 153852ad..092cb3f7 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ ERRATA - Improved adherence to Unicode by checking for non-character codepoints. Thanks Geoffrey Sneddon for reporting. This may result in degraded performance for extremely large inputs. +- Allow CSS property-value pair ''text-decoration: none'' . Added HTMLPurifier_UnitConverter and HTMLPurifier_Length for convenient handling of CSS-style lengths. HTMLPurifier_AttrDef_CSS_Length now uses this class. diff --git a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php index 501ab261..ab452780 100644 --- a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php +++ b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php @@ -15,10 +15,13 @@ class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef static $allowed_values = array( 'line-through' => true, 'overline' => true, - 'underline' => true + 'underline' => true, ); $string = strtolower($this->parseCDATA($string)); + + if ($string === 'none') return $string; + $parts = explode(' ', $string); $final = ''; foreach ($parts as $part) { diff --git a/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php b/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php index fb0ccf4f..84f11368 100644 --- a/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php +++ b/tests/HTMLPurifier/AttrDef/CSS/TextDecorationTest.php @@ -10,6 +10,9 @@ class HTMLPurifier_AttrDef_CSS_TextDecorationTest extends HTMLPurifier_AttrDefHa $this->def = new HTMLPurifier_AttrDef_CSS_TextDecoration(); + $this->assertDef('none'); + $this->assertDef('none underline', 'underline'); + $this->assertDef('underline'); $this->assertDef('overline'); $this->assertDef('line-through overline underline');