Express middleware for sanitizing user input using the Caja-HTML-Sanitizer (Google Caja sanitizer) to mitigate persistent XSS risks. Version 1.0.6 is available on npm. The package has been in maintenance mode since 2021; its core dependency (sanitizer) has not been updated in years. It adds a `req.sanitize()` method to Express request objects. Compared to alternatives like express-validator, this library is minimal but unmaintained and should be avoided in new projects.
npm install express-sanitizerVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up Express with express-sanitizer middleware and sanitizing a POST body property.
Migrate to a maintained alternative like express-validator or DOMPurify for server-side sanitization.
Ensure you call it: app.use(expressSanitizer());
Combine with express-validator or another validation library for comprehensive input handling.
Use require('express-sanitizer') instead of import.Call the module as a function: app.use(expressSanitizer());
Run npm install or explicitly add 'sanitizer' to your package.json.