From 8ee92112e48d52eb5dad5533075f3ab0aed658ba Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Aug 2018 12:08:45 -0300 Subject: [PATCH] Bug 13618: Add the escapeHtml JS prototype to String Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index db5539a6ec..fbbeed623f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -15,6 +15,16 @@ function formatstr(str, col) { }); } +var HtmlCharsToEscape = { + '&': '&', + '<': '<', + '>': '>' +}; +String.prototype.escapeHtml = function() { + return this.replace(/[&<>]/g, function(c) { + return HtmlCharsToEscape[c] || c; + }); +}; // http://stackoverflow.com/questions/14859281/select-tab-by-name-in-jquery-ui-1-10-0/16550804#16550804 $.fn.tabIndex = function () { -- 2.39.5