Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openwrt/luci.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-12-09 18:25:50 +0300
committerJo-Philipp Wich <jo@mein.io>2021-12-09 18:25:50 +0300
commit008bd893105d2bc8bfb5e5dce1ef00fa09008533 (patch)
treebd1c06c7f95a89242791255305c761dd6d0a133a
parent43818163155d5ce49414a8e54f5746a85606ba03 (diff)
luci-base: cbi.js: properly handle non-strings in `%h` and `%q` formats
Only replace null, objects and function values with the empty string but return booleans and numbers as strings. Spotted while debugging #5587. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 9200954d1e..324a91403f 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -521,9 +521,14 @@ String.prototype.format = function()
var quot_esc = [/"/g, '&#34;', /'/g, '&#39;'];
function esc(s, r) {
- if (typeof(s) !== 'string' && !(s instanceof String))
+ var t = typeof(s);
+
+ if (s == null || t === 'object' || t === 'function')
return '';
+ if (t !== 'string')
+ s = String(s);
+
for (var i = 0; i < r.length; i += 2)
s = s.replace(r[i], r[i+1]);