fix corner case in infinite recursion detection (#3926)

This commit is contained in:
Alex Lam S.L
2020-05-26 19:03:38 +01:00
committed by GitHub
parent 08af3eae44
commit 13c72a986c

View File

@@ -1177,7 +1177,7 @@ function skip_infinite_recursion(orig, toplevel) {
var code = orig;
var tries = [];
var offset = 0;
var re = /(?:(?:^|[\s{});])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g;
var re = /(?:(?:^|[\s{}):;])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g;
var match;
while (match = re.exec(code)) {
if (/}\s*finally\s*$/.test(match[0])) {
@@ -1185,7 +1185,7 @@ function skip_infinite_recursion(orig, toplevel) {
continue;
}
var index = match.index + match[0].length + 1;
if (/(?:^|[\s{});])try\s*$/.test(match[0])) {
if (/(?:^|[\s{}):;])try\s*$/.test(match[0])) {
tries.unshift({ try: index - offset });
continue;
}