Temporarily replace quote with jruderman's simpleSource

This commit is contained in:
pyoor 2017-06-15 17:24:32 -04:00
parent 0f8f02a654
commit 0bb9953ddb

View file

@ -25,24 +25,28 @@ utils.common = {
} }
return list return list
}, },
quote: function (obj) { quote: function (s) {
// Taken from DOMfuzz
function escapeString (s) { function escapeString (s) {
let escaped = s.replace(/\\/g, '\\\\') return ('\"' + // eslint-disable-line no-useless-escape
.replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape s.replace(/\\/g, '\\\\')
.replace(/\0/g, '\\0') .replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape
.replace(/\n/g, '\\n') .replace(/\0/g, '\\0')
.replace(/[^\0-~]/g, function (ch) { .replace(/\n/g, '\\n') +
return '\\u' + ('000' + ch.charCodeAt(0).toString(16)).slice(-4) '\"') // eslint-disable-line no-useless-escape
})
return '\"' + escaped + '\"' // eslint-disable-line no-useless-escape
} }
if (typeof s === 'string') { if (typeof s === 'string') {
return escapeString(obj) if (/^[\n\x20-\x7f]*$/.exec(s) || !self.uneval) { // eslint-disable-line no-undef
// Printable ASCII characters and line breaks: try to make it pretty.
return escapeString(s)
} else {
// Non-ASCII: use uneval to get \u escapes.
return uneval(s) // eslint-disable-line no-undef
}
} else { } else {
// For other things (such as numbers, |null|, and |undefined|), stringify // For other things (such as numbers, |null|, and |undefined|), just coerce to string.
return JSON.stringify(obj) return JSON.stringify(s)
} }
}, },
b64encode: function (str) { b64encode: function (str) {