Skip to content

Commit 3e2582f

Browse files
committed
Global: Fix filter for "on" attributes was too wide and replaced normal text containing " on" - refs #5887
Fix df47eac Advisory GHSA-8qqw-rjh4-5gp2
1 parent 00cdb85 commit 3e2582f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

main/inc/lib/formvalidator/FormValidator.class.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,14 +2102,10 @@ function plain_url_filter($html, $mode = NO_HTML)
21022102

21032103
/**
21042104
* Prevent execution of event handlers in HTML elements.
2105-
*
2106-
* @param string $html
2107-
*
2108-
* @return string
21092105
*/
2110-
function attr_on_filter($html)
2106+
function attr_on_filter(string $html): string
21112107
{
2112-
$prefix = uniqid('data-cke-').'-';
2108+
$pattern = '/\s*on\w+=(?:"[^"]*"|\'[^\']*\'|[^\s>]+)/i';
21132109

2114-
return preg_replace('/\b(on[a-z]+)\b\s*=/i', '$1'.$prefix.'$2', $html);
2110+
return preg_replace($pattern, '', $html);
21152111
}

0 commit comments

Comments
 (0)