Gumbo Sanitize is a loose port of the Ruby Sanitize library by Ryan Grove based on Google's Gumbo parser. This module differs from Sanitize.js in that it only supports nodejs and a subset of the Ruby Sanitize API.
npm install --save gumbo-sanitize
var sanitize = require("gumbo-sanitize");
console.log(sanitize("<img src=javascript:alert('XSS')>", sanitize.RELAXED));
// prints <img>
Alternatively, you may also use the Sanitize
class directly:
var Sanitize = require("gumbo-sanitize");
var s = new Sanitize(Sanitize.RELAXED);
console.log(s.sanitize("<img src=javascript:alert('XSS')>"));
For now, please see the source code for documentation. Open to contributions :)
MIT