Skip to content
Snippets Groups Projects
Commit 3bf92695 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #899 from greezybacon/issue/html-duplicate-styles


html: Remove duplicate style properties

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 0041bebc b3bb64c3
No related branches found
No related tags found
No related merge requests found
......@@ -178,13 +178,25 @@ class Format {
// Clean browser-specific style attributes
if (isset($attributes['style'])) {
$styles = preg_split('/;\s*/S', html_entity_decode($attributes['style']));
$props = array();
foreach ($styles as $i=>&$s) {
@list($prop, $val) = explode(':', $s);
if (isset($props[$prop])) {
unset($styles[$i]);
continue;
}
$props[$prop] = true;
// Remove unset or browser-specific style rules
if (!$val || !$prop || $prop[0] == '-' || substr($prop, 0, 4) == 'mso-')
unset($styles[$i]);
// Remove quotes of properties without enclosed space
if (!strpos($val, ' '))
$s = str_replace('"','', $s);
$val = str_replace('"','', $val);
else
$val = str_replace('"',"'", $val);
$s = "$prop:".trim($val);
}
unset($s);
if ($styles)
$attributes['style'] = Format::htmlencode(implode(';', $styles));
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment