Implement basic XSS filter
This commit is contained in:
parent
bf014530f9
commit
271a23cdad
2 changed files with 187 additions and 0 deletions
16
tests/xss.js
Normal file
16
tests/xss.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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.");
|
||||
Loading…
Add table
Add a link
Reference in a new issue