Last active
January 4, 2018 11:19
-
-
Save wiyoe/e313281cc2149b12e50a674283f93b62 to your computer and use it in GitHub Desktop.
Javascript htmlspecialchars.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function escapeHtml(text) { | |
| var map = { | |
| '&': '&', | |
| '<': '<', | |
| '>': '>', | |
| '"': '"', | |
| "'": ''' | |
| }; | |
| return text.replace(/[&<>"']/g, function(m) { return map[m]; }); | |
| } | |
| //http://jsfiddle.net/TheSharpieOne/uPw2U/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment