One of the things that I always wanted to do with ESAPI , was to have programmatic access to the multiple ESAPI encodings methods, since I believe they are a great example of the type of encodings capabilities that are needed in order to safely consume data provided by (potentially malicious) users.
ESAPI provides a number of sepecific methods to encode a string (each focused on a particular use case)
- encodeForHTML
- encodeForHTMLAttribute
- encodeForCSS
- encodeForJavascript
- encodeForVBScript
- encodeForLDAP
- encodeForDN
- encodeForXPath
- encodeForXML
- encodeForXmlAttribute
- encodeForURL
Well, using the View_ESAPI_Encodings Tbot page we can now answer that question:
Note that you can use this GUI to try out what a specific encoding looks like.
For example change the text on the left and click on of the ‘encodeFor…’ buttons
Other related ESAPI posts: