I came across the following xss fix. The old code was:
this.commentText = new Text(Sanitizer.sanitizeForHtml(commentText.getValue()));
The xss fix code is:
String sanitizedText = Sanitizer.sanitizeForHtml(commentText.getValue()).replace("\n", "\n<br>");
Can you please clarify to me how \n
can be used in XSS? and how replacing it with \n<br>
will solve the problem?
\n
to<br>
but I can't figure out why it shoud be replace by\n<br>
– Xavier59 Sep 20 '16 at 22:32