I am using org.owasp.esapi in a java project. I am using the ESAPI.encoder().forHTML() method for encoding the user input but this method encodes the '&' to "&" but I do not want to change the '&' so I want to whitelist the '&' character that the encoder does not encode it. So how can I change the ESAPI.properties file such that the encoder will whitelist this method.
please help me to find the properties which whitelist any character.
ESAPI intentionally doesn't provide an easy way for you to white-list additional characters. Many have asked for that without realizing the ramifications. (In this case, it could allow for attacks that come from double-encoding.) So the only way to do that is to write your own encoder to replace
org.owasp.esapi.reference.DefaultEncoderby specifying your own class for the ESAPI.Encoder property and we certainly do NOT recommend you doing that.That said, if I may ask, what specific problem are you trying to solve here? Usually there is just a specific field or two where some character they are required to allow to be rendered is one that is normally blocked and it comes out to be double-encoded so '&' shows up as '&' for instance. If you explain what the specific context is that you want to do, we can suggest alternatives that would be less dangerous than what you are suggesting.