3 ms·
Make sure to sanitize the content before inserting if you use this approach. > Warning: This is a security risk if the string to be inserted might contain pote
by busymom0 1y ago
Make sure to sanitize the content before inserting if you use this approach.
> Warning: This is a security risk if the string to be inserted might contain potentially malicious content. When inserting user-supplied data you should always consider using a sanitizer library, in order to sanitize the content before it is inserted.
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML https://developer.mozilla.org/en-US/docs/Web/API/Element/inn...
- reassess_blind 1y agoAnything with user input I just use innerText. Or a simple escapeHTML function within the innerHTML - but I prefer innerText in a separate pass, as using escapeHTML as a pattern gives an opportunity to forget to use it.