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

前端 未结 11 804
旧巷少年郎
旧巷少年郎 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:24

    As David shows, there's no easy way to protect with just some regexes you can always forget something, like javascript: in your case. You better escape the HTML entities on output. There is a lot of discussion about the best way to do this, depending on what you actually need to allow, but what's certain is that your function is not enough.

    Jeff has talked a bit about this here.

提交回复
热议问题