mirror of
https://github.com/metrico/qryn.git
synced 2025-03-14 10:07:18 +00:00
fix
This commit is contained in:
@ -81,32 +81,23 @@ compiler.ParseScript = function (script) {
|
|||||||
const aqLiterals = []
|
const aqLiterals = []
|
||||||
let _script = script
|
let _script = script
|
||||||
let res = ''
|
let res = ''
|
||||||
let qsMatch = _script.match(/^([^"]*)("([^"\\]|\\.)*")?/)
|
const re = /^([^"`]*)("(([^"\\]|\\.)*)"|`(([^`\\]|\\.)*)`)?/
|
||||||
|
let qsMatch = _script.match(re)
|
||||||
while (qsMatch && qsMatch[0]) {
|
while (qsMatch && qsMatch[0]) {
|
||||||
let repl = qsMatch[2] || ''
|
let repl = qsMatch[2] || qsMatch[4] || ''
|
||||||
if (repl.length > 512) {
|
if (repl.length > 512) {
|
||||||
qLiterals.push(repl)
|
if (repl.startsWith('"')) {
|
||||||
repl = `"QL_${qLiterals.length - 1}"`
|
qLiterals.push(repl)
|
||||||
|
repl = `"QL_${qLiterals.length - 1}"`
|
||||||
|
} else {
|
||||||
|
aqLiterals.push(repl)
|
||||||
|
repl = `\`AL_${aqLiterals.length - 1}\``
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res = res + qsMatch[1] + repl
|
res = res + qsMatch[1] + repl
|
||||||
_script = _script.slice(qsMatch[0].length)
|
_script = _script.slice(qsMatch[0].length)
|
||||||
qsMatch = _script.match(/^([^"]*)("([^"\\]|\\.)*")?/)
|
qsMatch = _script.match(re)
|
||||||
}
|
}
|
||||||
|
|
||||||
_script = res
|
|
||||||
res = ''
|
|
||||||
qsMatch = _script.match(/^([^`]*)(`([^`\\]|\\.)*`)?/)
|
|
||||||
while (qsMatch && qsMatch[0]) {
|
|
||||||
let repl = qsMatch[2] || ''
|
|
||||||
if (repl.length > 512) {
|
|
||||||
aqLiterals.push(repl)
|
|
||||||
repl = `\`AL_${qLiterals.length - 1}\``
|
|
||||||
}
|
|
||||||
res = res + qsMatch[1] + repl
|
|
||||||
_script = _script.slice(qsMatch[0].length)
|
|
||||||
qsMatch = _script.match(/^([^`]*)(`([^`\\]|\\.)*`)?/)
|
|
||||||
}
|
|
||||||
|
|
||||||
const parsedScript = this._ParseScript(res)
|
const parsedScript = this._ParseScript(res)
|
||||||
if (!parsedScript) {
|
if (!parsedScript) {
|
||||||
return parsedScript
|
return parsedScript
|
||||||
|
@ -85,9 +85,11 @@ module.exports.querySelectorPostProcess = (query) => {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
module.exports.unquoteToken = (token) => {
|
module.exports.unquoteToken = (token) => {
|
||||||
let value = token.Child('quoted_str').value
|
const value = token.Child('quoted_str').value
|
||||||
value = `"${value.substr(1, value.length - 2)}"`
|
if (value.startsWith('"')) {
|
||||||
return JSON.parse(value)
|
return JSON.parse(value)
|
||||||
|
}
|
||||||
|
return value.substr(1, value.length - 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user