groupoffice icon indicating copy to clipboard operation
groupoffice copied to clipboard

SanitizeHTML CSS comment fixup

Open polarismail opened this issue 2 years ago • 0 comments

There is an odd case where css style contains a comment and isn't properly caught by the current code in go/base/util/StringHelper.php ~ line 908

you have this regex: $html = preg_replace(["'<style>[\s]*<!--'u", "'-->[\s*]</style>'u"], ['<style>','</style>'], $html);

but I have seen cases where it's not enough and this following regex is more complete

$html = preg_replace(["'<style(\s*type=\"text/css\")?>[\s]*<!--'u", "'-->[\s*]</style>'u"], ['<style>','</style>'], $html);

or you could just match everything after style and up to the closing > tag

polarismail avatar Jul 04 '23 15:07 polarismail