Код: Выделить всё
function libraryCodeToCreateElement(text) {
const newElement = document.createElement('p');
newElement.innerHTML = text;
document.body.appendChild(newElement);
}
const untrustedText = 'some malicious string';
const sanitizingElement = document.createElement('span');
sanitizingElement.innerText = untrustedText;
libraryCodeToCreateElement(sanitizingElement.innerHTML);
Подробнее здесь: https://stackoverflow.com/questions/796 ... ss-attacks