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

Merge pull request #784 from greezybacon/issue/html-style-cleanup


html: Avoid corrupting quoted style attributes

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents bdfb2f13 ed2b2c68
No related branches found
No related tags found
No related merge requests found
......@@ -167,7 +167,7 @@ class Format {
if (isset($attributes['class'])) {
$classes = explode(' ', $attributes['class']);
foreach ($classes as $i=>$a)
// Unset all unsupported style classes -- anything by M$
// Unset all unsupported style classes -- anything but M$
if (strpos($a, 'Mso') !== 0)
unset($classes[$i]);
if ($classes)
......@@ -177,14 +177,16 @@ class Format {
}
// Clean browser-specific style attributes
if (isset($attributes['style'])) {
$styles = explode(';', $attributes['style']);
foreach ($styles as $i=>$s) {
$styles = preg_split('/;\s*/S', html_entity_decode($attributes['style']));
foreach ($styles as $i=>&$s) {
@list($prop, $val) = explode(':', $s);
if (!$val || !$prop || $prop[0] == '-')
if (!$val || !$prop || $prop[0] == '-' || substr($prop, 0, 4) == 'mso-')
unset($styles[$i]);
if (!strpos($val, ' '))
$s = str_replace('"','', $s);
}
if ($styles)
$attributes['style'] = implode(';', $styles);
$attributes['style'] = Format::htmlencode(implode(';', $styles));
else
unset($attributes['style']);
}
......@@ -246,7 +248,7 @@ class Format {
}
function htmlencode($var) {
$flags = ENT_COMPAT | ENT_QUOTES;
$flags = ENT_COMPAT;
if (phpversion() >= '5.4.0')
$flags |= ENT_HTML401;
......
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