I have byte array with html and try to escape. I convert byte array to string and replace special characters. When I make replace, my html doesnt work properly. It looks like a string and no css.
How to make properly ?
String x= IOUtils.toString(getPdf(), "UTF-8");
String secureX = replaceXssCharacters(x);
return ResponseEntity.ok().contentType(
MediaType.TEXT_HTML).body(secureX);
private String replaceXssCharacters(String value) {
if (value != null) {
return value
.replace("&","&")
.replace("<", "<")
.replace(">",">")
.replace("\"",""")
.replace("'","'");
}
return null;
}