From 3db65d79c6ad21e26290764203f4a46a247b99eb Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Jan 2020 16:46:46 +0100 Subject: [PATCH 1/2] js: Fix improper parsing in `utils.parseParams()` --- public/js/icinga/utils.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index 8b2a90921..60902705b 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -198,15 +198,28 @@ segment = a.search.replace(/^\?/,'').split('&'), len = segment.length, i = 0, - s; + s, + key, + value, + equalPos; for (; i < len; i++) { - if (!segment[i]) { + if (! segment[i]) { continue; } - s = segment[i].split('='); - params[decodeURIComponent(s[0])] = typeof s[1] !== 'undefined' ? decodeURIComponent(s[1]) : null; + + equalPos = segment[i].indexOf('='); + if (equalPos !== -1) { + key = segment[i].slice(0, equalPos); + value = segment[i].slice(equalPos + 1); + } else { + key = segment[i]; + value = null; + } + + params[key] = value; } + return params; }, From fdd14c96b144fd00eac923987b26a4f66fd3da60 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Jan 2020 16:47:30 +0100 Subject: [PATCH 2/2] js: Only encode new params in `utils.addUrlParams()` --- public/js/icinga/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/icinga/utils.js b/public/js/icinga/utils.js index 60902705b..8c9ac74fa 100644 --- a/public/js/icinga/utils.js +++ b/public/js/icinga/utils.js @@ -133,7 +133,7 @@ $.each(params, function (key, value) { // We overwrite existing params - newparams[key] = value; + newparams[encodeURIComponent(key)] = encodeURIComponent(value); }); if (Object.keys(newparams).length) { @@ -143,9 +143,9 @@ queryString += '&'; } - queryString += encodeURIComponent(key); + queryString += key; if (value !== null) { - queryString += '=' + encodeURIComponent(value); + queryString += '=' + value; } }); result += queryString;