Preventing XSS in Node.js / server side javascript

后端 未结 8 1897
花落未央
花落未央 2020-12-07 10:24

Any idea how one would go about preventing XSS attacks on a node.js app? Any libs out there that handle removing javascript in hrefs, onclick attributes,etc. from POSTed dat

相关标签:
8条回答
  • 2020-12-07 11:12

    In newer versions of validator module you can use the following script to prevent XSS attack:

      var validator = require('validator');
    
      var escaped_string = validator.escape(someString);
    
    0 讨论(0)
  • 2020-12-07 11:15

    I've created a module that bundles the Caja HTML Sanitizer

    npm install sanitizer
    

    http://github.com/theSmaw/Caja-HTML-Sanitizer

    https://www.npmjs.com/package/sanitizer

    Any feedback appreciated.

    0 讨论(0)
提交回复
热议问题