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:
parent
4381816315
commit
008bd89310
1 changed files with 6 additions and 1 deletions
|
@ -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]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue