mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-15 03:52:06 +00:00
17 lines
502 B
JavaScript
17 lines
502 B
JavaScript
|
|
var sanitize = require('../lib/xss').sanitizeHTML;
|
||
|
|
var assert = require('assert');
|
||
|
|
|
||
|
|
function basicTest() {
|
||
|
|
assert(sanitize("< script src = bad.js>blah</script>") ===
|
||
|
|
"[tag removed]blah[tag removed]");
|
||
|
|
|
||
|
|
assert(sanitize("< img src=asdf onerror='alert(\"xss\")'>") ===
|
||
|
|
"<img src=\"asdf\">");
|
||
|
|
|
||
|
|
assert(sanitize("<a href='javascript:alert(document.cookie)'>") ===
|
||
|
|
"<a href=\":()\">");
|
||
|
|
}
|
||
|
|
|
||
|
|
basicTest();
|
||
|
|
console.log("Tests passed.");
|