Only escape minimal characters and allow HTML escapes

This commit is contained in:
pyoor 2018-08-02 14:26:17 -04:00
parent 195411fe8d
commit 80f16a4aaf

View file

@ -30,11 +30,22 @@ class common extends utils {
return list return list
} }
static quote (s) { /**
* Escape and quote a string
* @param s {string} - String to be quoted
* @param html {boolean} - Identifies whether the string must be HTML safe
* @returns {*}
*/
static quote (s, html = false) {
const options = {
minimal: true,
isScriptContext: html
}
if (typeof s === 'string') { if (typeof s === 'string') {
return `'${jsesc(s)}'` return `'${jsesc(s, options)}'`
} else { } else {
return jsesc(s) return jsesc(s, options)
} }
} }