Skip to content

Instantly share code, notes, and snippets.

@Timoteus78
Created August 17, 2014 16:34
Show Gist options
  • Save Timoteus78/b9a2d9ba3f723746c0b8 to your computer and use it in GitHub Desktop.
Save Timoteus78/b9a2d9ba3f723746c0b8 to your computer and use it in GitHub Desktop.
Preventing cross-site scripting by @thomasdavis
function htmlEncode(value){
return $('<div/>').text(value).html();
}
function htmlDecode(value){
return $('<div/>').html(value).text();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment