diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index 933969cb..1f206874 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -88,7 +88,7 @@ function initTable() { $("td:eq(2)", row).html(''); var commentEl = $("#comment_" + data.id, row); - commentEl.val(data.comment); + commentEl.val(utils.unescapeHtml(data.comment)); commentEl.on("change", editAdlist); $("td:eq(3)", row).empty(); diff --git a/scripts/pi-hole/js/groups-clients.js b/scripts/pi-hole/js/groups-clients.js index 5de4d838..31139d3f 100644 --- a/scripts/pi-hole/js/groups-clients.js +++ b/scripts/pi-hole/js/groups-clients.js @@ -132,7 +132,7 @@ function initTable() { $("td:eq(1)", row).html(''); var commentEl = $("#comment_" + data.id, row); - commentEl.val(data.comment); + commentEl.val(utils.unescapeHtml(data.comment)); commentEl.on("change", editClient); $("td:eq(2)", row).empty(); diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index ce00d5b3..61c057dc 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -149,7 +149,7 @@ function initTable() { $("td:eq(3)", row).html(''); var commentEl = $("#comment_" + data.id, row); - commentEl.val(data.comment); + commentEl.val(utils.unescapeHtml(data.comment)); commentEl.on("change", editDomain); // Show group assignment field only if in full domain management mode diff --git a/scripts/pi-hole/js/groups.js b/scripts/pi-hole/js/groups.js index ed88ecb9..5dbfa458 100644 --- a/scripts/pi-hole/js/groups.js +++ b/scripts/pi-hole/js/groups.js @@ -43,7 +43,7 @@ $(function () { '' ); var nameEl = $("#name_" + data.id, row); - nameEl.val(data.name); + nameEl.val(utils.unescapeHtml(data.name)); nameEl.on("change", editGroup); var disabled = data.enabled === 0; @@ -63,7 +63,7 @@ $(function () { $("td:eq(2)", row).html(''); var desc = data.description !== null ? data.description : ""; var descEl = $("#desc_" + data.id, row); - descEl.val(desc); + descEl.val(utils.unescapeHtml(desc)); descEl.on("change", editGroup); $("td:eq(3)", row).empty(); diff --git a/scripts/pi-hole/js/utils.js b/scripts/pi-hole/js/utils.js index 002f4c30..6fe90245 100644 --- a/scripts/pi-hole/js/utils.js +++ b/scripts/pi-hole/js/utils.js @@ -22,6 +22,20 @@ function escapeHtml(text) { }); } +function unescapeHtml(text) { + var map = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'" + }; + + return text.replace(/&(?:amp|lt|gt|quot|#039);/g, function (m) { + return map[m]; + }); +} + // Helper function for converting Objects to Arrays after sorting the keys function objectToArray(obj) { var arr = []; @@ -233,6 +247,7 @@ function getGraphType() { window.utils = (function () { return { escapeHtml: escapeHtml, + unescapeHtml: unescapeHtml, objectToArray: objectToArray, padNumber: padNumber, showAlert: showAlert,