If one performs HTML and Javascript encoding on the html content to prevent XSS (using
ESAPI,Encoder.encodeForJS(Encoder.encodeForHTML(untrustedData)))
before sending the response to the client.
How to handle this HTML and Javascript encoded data in javascript?
Do I have to canonicalise the data before using the server output in element.innerHTML.
e.g,
var data = $ESAPI.encoder().canonicalize(serverOP);
element.innerHTML=data;
But canonicalising data with mixed or multiple encoding will throw exception (Intrusion exception).