Preventing XSS in Node.js / server side javascript

后端 未结 8 1973
花落未央
花落未央 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:09

    Try out the npm module strip-js. It performs the following actions:

    • Sanitizes HTML
    • Removes script tags
    • Removes attributes such as "onclick", "onerror", etc. which contain JavaScript code
    • Removes "href" attributes which contain JavaScript code

    https://www.npmjs.com/package/strip-js

提交回复
热议问题