This page describes the mechanisms in Liferay to escape characters.
All the escape methods are designed to prevent XSS attacks and follows OWASP's recommendations for escaping. They can be found in the class HtmlUtil:
Functions:
____________________________________________________________________
All the escape methods are designed to prevent XSS attacks and follows OWASP's recommendations for escaping. They can be found in the class HtmlUtil:
Functions:
____________________________________________________________________
- HtmlUtil.escape() is for inserting untrusted data into an HTML element
- HtmlUtil.escapeHREF() is for inserting full URLs into the href attribute
- HtmlUtil.escapeURL() is for inserting untrusted data into URL parameter values
- HtmlUtil.escapeAttribute() is for inserting untrusted data into HTML element attribute values
- HtmlUtil.escapeCSS() is for inserting untrusted data into CSS property values
- HtmlUtil.escapeJS() is for inserting untrusted data into JavaScript strings
Rule 1 : Don't escape before persisting
There's a few reason why it's generally a bad idea to escape the data before it's persisted.- It increases the size of the data that must be stored
- You may need the original at some point in the future. If the data is escaped already, it'll be very difficult to get back the original.
No comments:
Post a Comment