Is it 100% safe to do the following?:
var untrusted_input_from_3rd_party = '<script>alert("xss")<\/script>';
document.getElementsByTagName('body')[0].appendChild(document.createTextNode(untrusted_input_from_3rd_party));
Considering that the third party can input anything (HTML, CSS, etc.), can I be sure it won't do any harm if I pass it through createTextNode
and then add it to the dom?