0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-03 05:11:52 +00:00

Check if element without attribute is allowed

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2021-08-10 18:36:17 +02:00
parent c97bb93223
commit 70c39dd289
No known key found for this signature in database
GPG Key ID: 36E3664E099D0614
2 changed files with 17 additions and 0 deletions

View File

@ -243,6 +243,10 @@ class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter
if ($y === '*' || isset($html_definition->info[$y = strtolower($y)])) { if ($y === '*' || isset($html_definition->info[$y = strtolower($y)])) {
$nx = $y; $nx = $y;
} else { } else {
$components2 = explode('[', $y);
if (count($components2) === 2 && isset($html_definition->info[$y2 = strtolower($components2[0])])) {
$nx = $y2;
}
// $nx stays null; this matters // $nx stays null; this matters
// if we don't manage to find // if we don't manage to find
// any valid selector content, // any valid selector content,

View File

@ -262,6 +262,19 @@ text-align:center
$this->assertExtractStyleBlocks("<style></style>" . $goo, $goo, array('')); $this->assertExtractStyleBlocks("<style></style>" . $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 // vim: et sw=4 sts=4