browsers:

w3docs logo Javascript decoding the HTML
function htmlDecode(input) {
let doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
alert(htmlDecode("&lt;img src='img.jpg'&gt;")); // "<img src='myimage.jpg'>"
alert(htmlDecode("<img src='dummy' onerror='alert(/xss/)'>")); // ""
 
The function

Post a Comment

0 Comments