[icinga-checkins] icinga.org: icingaweb2/bugfix/js-close-container-8590: JS: implement Icinga.Utils.escape()

git at icinga.org git at icinga.org
Mon Feb 22 13:38:13 CET 2016


Module: icingaweb2
Branch: bugfix/js-close-container-8590
Commit: a493c3469cacc5b97962da34de39d8156ec7de00
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=a493c3469cacc5b97962da34de39d8156ec7de00

Author: Alexander A. Klimov <alexander.klimov at netways.de>
Date:   Fri Feb 19 14:05:05 2016 +0100

JS: implement Icinga.Utils.escape()

---

 public/js/icinga/utils.js |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js
index b3b6a95..dea9c37 100644
--- a/public/js/icinga/utils.js
+++ b/public/js/icinga/utils.js
@@ -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 {
+                        '&': '&',
+                        '<': '<',
+                        '>': '>',
+                        '"': '"',
+                        "'": '''
+                    }[c];
+                }
+            );
         }
     };
 



More information about the icinga-checkins mailing list