dompurify
Version:
DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else usin
18 lines (13 loc) • 593 B
JavaScript
/* jshint globalstrict:true, node:true */
;
var he = require('he');
var fs = require('fs');
var tests = JSON.parse(fs.readFileSync('./test/expect.json', 'utf-8'));
var allTests = tests.reduce(function(previousValue, currentValue) {
return previousValue + '\n' + currentValue.payload;
}, '').trim();
var allTestsEscaped = he.encode(allTests);
var template = fs.readFileSync('./demo/index.tpl', 'utf-8');
// Poor man’s templating engine, aka. `String#replace`:
var result = template.replace(/<%- examples %>/, allTestsEscaped);
fs.writeFileSync('./demo/index.html', result);