-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi,
I found myself on this situation where I have a valid non executable HTML with inline events, which were removed by the filter. At first sight this should be the expected behavior, but in my case I'm using the filter on user input data that documents HTML code, so these events are expected if the affected tags are inside of <pre> or <code> ones.
I believe this line https://github.com/MasterRO94/laravel-xss-filter/blob/master/src/Cleaner.php#L74 can be safely replace with
$string = preg_replace_callback($this->invalidHtmlInlineListenersPattern, [$this, 'escapeEqualSign'], $string);
// ...
protected function escapeEqualSign(array $matches): string
{
return str_replace('=', '=', $matches[0]);
}
But I'm not sure about how to prevent the javascript:code attack using escaped replacements.
Let me know what do you think and if you believe this is enough to propose a pull request (or feel free to apply the changes directly if you like).
BTW, thanks for your work on this middleware.