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>
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]);