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
1 changed files with 17 additions and 13 deletions

View File

@ -25,24 +25,28 @@ utils.common = {
}
return list
},
quote: function (obj) {
quote: function (s) {
// Taken from DOMfuzz
function escapeString (s) {
let escaped = s.replace(/\\/g, '\\\\')
.replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape
.replace(/\0/g, '\\0')
.replace(/\n/g, '\\n')
.replace(/[^\0-~]/g, function (ch) {
return '\\u' + ('000' + ch.charCodeAt(0).toString(16)).slice(-4)
})
return '\"' + escaped + '\"' // eslint-disable-line no-useless-escape
return ('\"' + // eslint-disable-line no-useless-escape
s.replace(/\\/g, '\\\\')
.replace(/\"/g, '\\\"') // eslint-disable-line no-useless-escape
.replace(/\0/g, '\\0')
.replace(/\n/g, '\\n') +
'\"') // eslint-disable-line no-useless-escape
}
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 {
// For other things (such as numbers, |null|, and |undefined|), stringify
return JSON.stringify(obj)
// For other things (such as numbers, |null|, and |undefined|), just coerce to string.
return JSON.stringify(s)
}
},
b64encode: function (str) {