Skip to content

Instantly share code, notes, and snippets.

@jakearchibald
Created December 23, 2009 11:56
Show Gist options
  • Save jakearchibald/262482 to your computer and use it in GitHub Desktop.
Save jakearchibald/262482 to your computer and use it in GitHub Desktop.
function h(str) {
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&#34;')
.replace(/'/g, '&#39;')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment