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
"); } }, });