From 580ab99a723cbe616eeb4bfbe0e80e621bf32a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 22 Mar 2019 18:09:47 +0100 Subject: [PATCH] Escape characters in admin-module also --- .../assets/admin/authenticated/js/main.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/public/assets/admin/authenticated/js/main.js b/server/public/assets/admin/authenticated/js/main.js index 643da14d..72c083e7 100644 --- a/server/public/assets/admin/authenticated/js/main.js +++ b/server/public/assets/admin/authenticated/js/main.js @@ -678,6 +678,18 @@ function add_to_tab(dest, resp){ } } +function escapeHtml(text) { + var map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); +} + function increaseInfo(num) { removeClass(".info-badge", "hide"); try { @@ -778,9 +790,10 @@ function loaded() { for(var i = 0; i < response.length; i++) { var icon = ""; if(response[i].icon && response[i].icon != "") { - icon = "" + response[i]._id + ""; + icon = "" + escapeHtml(response[i]._id) + ""; } - document.querySelector(".names-container").insertAdjacentHTML("beforeend", "
" + icon + response[i]._id + "
checkclose
"); + + document.querySelector(".names-container").insertAdjacentHTML("beforeend", "
" + icon + escapeHtml(response[i]._id) + "
checkclose
"); } }, });