Web Security · Junior · Question 24 of 75
What does an HTML sanitizer such as DOMPurify do?
- 1Minifies HTML to make pages load faster
- 2Encrypts HTML so that only the server can read it
- ✓Correct answer: Parses HTML and removes dangerous elements and attributes, keeping safe formatting
Explanation
When you really need user HTML (a rich-text editor, for example), a well-maintained sanitizer strips <script>, event handlers like onerror and dangerous URLs.