Overview of the Sanitizer API
mainThe Sanitizer API is a browser-native API designed to provide a safe, easy-to-use, and browser-maintained way to sanitize HTML strings. Its primary purpose is to prevent accidental JavaScript execution when rendering user-generated content or client-side templates. By being part of the web platform, the API is updated alongside the browser's parser, ensuring protection against new attack vectors without requiring manual library updates.
Key Characteristics:
- User Input Sanitization: Converts potentially unsafe HTML strings into safe versions that do not trigger inadvertent script execution.
- Browser-Maintained: As an "ever-green" part of the web platform, it benefits from automatic updates to the browser's security and parsing logic.
- Safe Defaults: Designed with a small API surface and sensible defaults to make common sanitization tasks easy and secure by default.
Note on Status: The API is currently being incubated and is not yet finalized. It is moving toward being part of the WHATWG HTML specification.