Skip to content

Instantly share code, notes, and snippets.

@batica81
Created September 20, 2019 13:06
Show Gist options
  • Save batica81/b981e4ac0474f66da8d5cb075e6332c5 to your computer and use it in GitHub Desktop.
Save batica81/b981e4ac0474f66da8d5cb075e6332c5 to your computer and use it in GitHub Desktop.
// A simple way to protect from some XSS attacks
var sanitizeHTML = function (str) {
var temp = document.createElement('div');
temp.textContent = str;
return temp.innerHTML;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment