thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Application & OT Security · Intermediate

HTML Sanitization

Removing or neutralizing dangerous elements and attributes from user-supplied HTML while keeping safe formatting.

Definition

When applications must accept rich text, encoding would break the formatting, so a well-maintained allowlist-based sanitizer such as DOMPurify is used. Homegrown regex sanitizers are routinely bypassed.

Example

A blog comment editor passes HTML through DOMPurify before saving and rendering.

Exam tip

Sanitize when HTML is required; otherwise encode. Never write your own regex filter.

Related terms