mirror of
https://github.com/openwrt/luci.git
synced 2025-12-27 05:24:58 +04:00
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>
This commit is contained in:
@@ -521,9 +521,14 @@ String.prototype.format = function()
|
||||
var quot_esc = [/"/g, '"', /'/g, '''];
|
||||
|
||||
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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user