0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 23:28:42 +00:00

Make CSS validator drop duplicate declarations.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@225 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-08-13 04:52:40 +00:00
parent bb2a30ee97
commit d721066d27
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,7 @@ class HTMLPurifier_AttrDef_CSS
// This is because semicolon rarely appears in escaped form
$declarations = explode(';', $css);
$new_declarations = '';
$propvalues = array();
foreach ($declarations as $declaration) {
if (!$declaration) continue;
@ -23,7 +23,12 @@ class HTMLPurifier_AttrDef_CSS
if (!isset($definition->info[$property])) continue;
$result = $definition->info[$property]->validate($value,$config,$context);
if ($result === false) continue;
$new_declarations .= "$property:$result;";
$propvalues[$property] = $result;
}
$new_declarations = '';
foreach ($propvalues as $prop => $value) {
$new_declarations .= "$prop:$value;";
}
return $new_declarations ? $new_declarations : false;

View File

@ -10,6 +10,7 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
$this->def = new HTMLPurifier_AttrDef_CSS();
$this->assertDef('text-align:right;');
$this->assertDef('text-align:right;text-align:left;', 'text-align:left;');
}