From f38fca32a9bad0952df221f8664ee2ab13978504 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 2 Jun 2012 11:22:58 -0400 Subject: [PATCH] Don't lower-case components of background. Signed-off-by: Edward Z. Yang --- NEWS | 2 ++ library/HTMLPurifier/AttrDef/CSS/Background.php | 2 +- library/HTMLPurifier/Filter/ExtractStyleBlocks.php | 1 + tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php | 4 ++++ tests/HTMLPurifier/URISchemeTest.php | 6 ++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1678a939..6c437235 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier ! Support display:inline-block - Use prepend for SPL autoloading on PHP 5.3 and later. - Fix bug with nofollow transform when pre-existing rel exists. +- Fix bug where background:url() always gets lower-cased + (but not background-image:url()) 4.4.0, released 2012-01-18 # Removed PEARSax3 handler. diff --git a/library/HTMLPurifier/AttrDef/CSS/Background.php b/library/HTMLPurifier/AttrDef/CSS/Background.php index 3a3d20cd..e5b7438c 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Background.php +++ b/library/HTMLPurifier/AttrDef/CSS/Background.php @@ -32,7 +32,7 @@ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef $string = $this->mungeRgb($string); // assumes URI doesn't have spaces in it - $bits = explode(' ', strtolower($string)); // bits to process + $bits = explode(' ', $string); // bits to process $caught = array(); $caught['color'] = false; diff --git a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php index 320aa4f1..df937ace 100644 --- a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php +++ b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php @@ -33,6 +33,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter public function __construct() { $this->_tidy = new csstidy(); + $this->_tidy->set_cfg('lowercase_s', false); $this->_id_attrdef = new HTMLPurifier_AttrDef_HTML_ID(true); $this->_class_attrdef = new HTMLPurifier_AttrDef_CSS_Ident(); $this->_enum_attrdef = new HTMLPurifier_AttrDef_Enum(array('first-child', 'link', 'visited', 'active', 'hover', 'focus')); diff --git a/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php b/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php index 3466d6aa..a166022a 100644 --- a/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php +++ b/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php @@ -226,6 +226,10 @@ text-align:center; $this->assertCleanCSS("doesnt-exist { text-align:center }", ""); } + function test_cleanCSS_caseSensitive() { + $this->assertCleanCSS("a .foo #ID div.cl#foo {\nbackground:url(\"http://foo/BAR\");\n}"); + } + } // vim: et sw=4 sts=4 diff --git a/tests/HTMLPurifier/URISchemeTest.php b/tests/HTMLPurifier/URISchemeTest.php index 4b43310b..cbd4fc58 100644 --- a/tests/HTMLPurifier/URISchemeTest.php +++ b/tests/HTMLPurifier/URISchemeTest.php @@ -33,6 +33,12 @@ class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness ); } + function test_http_uppercase() { + $this->assertValidation( + 'http://example.com/FOO' + ); + } + function test_http_removeDefaultPort() { $this->assertValidation( 'http://example.com:80', -- 2.11.4.GIT