From e907c0c89788b71c2056bd704a162fc0d6dd17f7 Mon Sep 17 00:00:00 2001 From: Sijia Zhao Date: Tue, 19 May 2020 18:47:16 +0100 Subject: [PATCH] Prevent special characters in DlgFromDict dictionary causing DOM element selection problems Use $.escapeSelector() Requires jQuery 3.0+ --- js/core/GUI.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/core/GUI.js b/js/core/GUI.js index 74578a1..26dedce 100644 --- a/js/core/GUI.js +++ b/js/core/GUI.js @@ -130,7 +130,7 @@ export class GUI htmlCode += '
'; for (const key in dictionary) { const value = dictionary[key]; - const keyId = key + '_id'; + const keyId = $.escapeSelector(key) + '_id'; // only create an input if the key is not in the URL: let inUrl = false; @@ -200,7 +200,7 @@ export class GUI // setup change event handlers for all required keys: for (const key of this._requiredKeys) { - const keyId = key + '_id'; + const keyId = $.escapeSelector(key) + '_id'; const input = document.getElementById(keyId); if (input) input.onchange = (event) => GUI._onKeyChange(self, event); @@ -227,7 +227,7 @@ export class GUI // update dictionary: for (const key in dictionary) { - const input = document.getElementById(key + "_id"); + const input = document.getElementById($.escapeSelector(key) + "_id"); if (input) dictionary[key] = input.value; }