Fix #57897 ignore object valued scripts

This commit is contained in:
Erich Gamma 2018-09-17 20:53:58 +02:00
parent cd20626929
commit 295f04ae24

View file

@ -352,6 +352,7 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
let visitor: JSONVisitor = {
onError(_error: ParseErrorCode, _offset: number, _length: number) {
console.log(_error);
},
onObjectEnd() {
if (inScripts) {
@ -368,8 +369,10 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
if (property === 'scripts') {
inScripts = true;
}
else if (inScripts) {
else if (inScripts && !script) {
script = property;
} else { // nested object which is invalid, ignore the script
script = undefined;
}
}
};