mewebstudio / Purifier

HTMLPurifier for Laravel 5/6/7/8/9/10/11
MIT License
1.87k stars 230 forks source link

HTML Codes are replaced by HTML Entities #170

Open Arnauec opened 2 years ago

Arnauec commented 2 years ago

I have the following scenario which is somewhat related with this, but I haven't been able to fix it using the suggested solution: my application has an input field, it cleans it using the Purifier and then dumps the response.

When I receive the following input: <img src=x onerror=alert(1)> and I purify it, it becomes: <img src=x>

Nevertheless, when I receive the following input: &#60img src=x onerror=alert(document.cookie)&#62; and I purify it, it becomes: &lt;img src=x onerror=alert(document.cookie)&gt;

I assume this is not expected behaviour, as the alert(document.cookie) is not sanitized. This is leading to XSSs in several parts of the application. What is the recommended way to clean this?

Thanks!