All escaping functions replace HTML reserved characters.

This commit is contained in:
Chad Weider 2012-01-14 14:46:15 -08:00
parent 30da7357e5
commit 6e36b59a59
4 changed files with 20 additions and 5 deletions

View file

@ -23,7 +23,14 @@
var padutils = {
escapeHtml: function(x)
{
return String(x).replace(/\</g, '&lt;').replace(/\>/g, '&gt;');
return String(x).replace(/[&"<>]/g, function (c) {
return {
'&': '&amp;',
'"': '&quot;',
'<': '&lt;',
'>': '&gt;'
}[c] || c;
});
},
uniqueId: function()
{