diff --git a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php
index 66f70b0f..090b115e 100644
--- a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php
+++ b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php
@@ -243,6 +243,10 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
if ($y === '*' || isset($html_definition->info[$y = strtolower($y)])) {
$nx = $y;
} else {
+ $components2 = explode('[', $y);
+ if (count($components2) === 2 && isset($html_definition->info[$y2 = strtolower($components2[0])])) {
+ $nx = $y2;
+ }
// $nx stays null; this matters
// if we don't manage to find
// any valid selector content,
diff --git a/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php b/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php
index e0c398f7..168041a2 100644
--- a/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php
+++ b/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php
@@ -262,6 +262,19 @@ text-align:center
$this->assertExtractStyleBlocks("" . $goo, $goo, array(''));
}
+ public function test_cleanCSS_elementWithAttribute()
+ {
+ $this->assertCleanCSS(
+ "* img[tabindex=\"0\"] + div {\ntext-align:center\n}",
+ "* img + div {\ntext-align:center\n}"
+ );
+ }
+
+ public function test_cleanCSS_descendantSelector()
+ {
+ $this->assertCleanCSS("* img + div {\ntext-align:center\n}");
+ }
+
}
// vim: et sw=4 sts=4