JS: implement Icinga.Utils.escape()

This commit is contained in:
Alexander A. Klimov 2016-02-19 14:05:05 +01:00
parent 4cd2469a5f
commit a493c3469c
1 changed files with 15 additions and 0 deletions

View File

@ -371,6 +371,21 @@
return encodeURIComponent(str).replace(/[()]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
},
escape: function (str) {
return String(str).replace(
/[&<>"']/gm,
function (c) {
return {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
}[c];
}
);
}
};