How to prevent JavaScript injection (XSS) when JSTL escapeXml is false

后端 未结 3 1996
春和景丽
春和景丽 2020-12-20 10:52

I have a form that people can add their stuff. However, in that form, if they enter JavaScript instead of only text, they can easily inject whatever they want to do. In orde

3条回答
  •  渐次进展
    2020-12-20 11:24

    You need to parse the HTML text on the server as XML, then throw out any tags and attributes that aren't in a strict whitelist.
    (And check the URLs in href and src attributes)

提交回复
热议问题