Does this set of regular expressions FULLY protect against cross site scripting?

前端 未结 11 805
旧巷少年郎
旧巷少年郎 2020-12-13 11:35

What\'s an example of something dangerous that would not be caught by the code below?

EDIT: After some of the comments I added another line, commented below. See V

11条回答
  •  一整个雨季
    2020-12-13 12:22

    example
    

    Any time you can write a string to the document, a big door swings open.

    There are myriad places to inject malicious things into HTML/JavaScript. For this reason, Facebook didn't initially allow JavaScript in their applications platform. Their solution was to later implement a markup/script compiler that allows them to seriously filter out the bad stuff.

    As said already, whitelist a few tags and attributes and strip out everything else. Don't blacklist a few known malicious attributes and allow everything else.

提交回复
热议问题