Make ${} operator XSS safe in Struts 2 (same as tapestry)

 ̄綄美尐妖づ 提交于 2019-11-27 05:38:46
  1. Struts2 <s:property value="name" /> is automatically escaped by default;
  2. JSTL <c:out value="${name}" /> is automatically escaped by default;
  3. JSP EL ${name} is NOT escaped.

You can explicitly escape it with ${fn:escapeXml(name)} , or set the escape to be performed by default creating a custom ELResolver as described in this great article:

Short answer: make it safe either on entry into the app, or on the way to the view layer.

Tapestry's ${} is safe because it's not using JSP/JSP EL. Not escaping stuff is one of the things you lose by using JSP EL's ${} over things like <c:out> and so on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!