luci-base: cbi.js: handle undefined arguments in formatting
Fix the JavaScript String.format() to not trigger an exception if the argument for an escaped format like %h or %q is undefined. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
bd4534496a
commit
6a11f71758
1 changed files with 3 additions and 0 deletions
|
@ -1300,6 +1300,9 @@ String.prototype.format = function()
|
|||
var quot_esc = [/"/g, '"', /'/g, '''];
|
||||
|
||||
function esc(s, r) {
|
||||
if (typeof(s) !== 'string' && !(s instanceof String))
|
||||
return '';
|
||||
|
||||
for( var i = 0; i < r.length; i += 2 )
|
||||
s = s.replace(r[i], r[i+1]);
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue