diff options
author | Jo-Philipp Wich <jo@mein.io> | 2016-08-04 11:45:04 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2016-08-04 11:45:30 +0200 |
commit | 6a11f71758e151d85eaf1bb611808f2420717ef7 (patch) | |
tree | 08a72cd7b072220f3bd55ab0abe801968f09a9e8 /modules/luci-base/htdocs/luci-static/resources | |
parent | bd4534496a9e3fc1f1c33b7e8aafb7c41f2afad2 (diff) |
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>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index b285ee26cc..5790e303dd 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -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; |