JSFiddle - React, Tailwind, and code Playground
by Anonymous
HTML
<body id="demo">
<p>Click the button to display the character of the specified unicode number.</p>
<button onclick="myFunction()">Try it</button>
<p ></p>
</body>
JavaScript
var attackStr = "\u003cscript type='text/javascript'\u003e function(){alert('p4wn3d!')}()\; \u003c/script\u003e";
function convertStringToCharCodeArray(inputStr){
var outputArray = [];
for(var i = 0; i < inputStr.length; i++){
outputArray.push(inputStr.charCodeAt(i));
}
return outputArray;
}
var charCodeSAttacktr = convertStringToCharCodeArray(attackStr);
function myFunction() {
//var charCodeArray = [72, 69, 76, 76, 79];
var res = String.fromCharCode.apply(String, charCodeSAttacktr);
eval(res);
document.getElementById("demo").innerHTML = res;
}