[Pkg-javascript-commits] [node-acorn-jsx] 273/484: [loose parser] Be more careful about calling resetTo
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 6c854ad221bc420396963710d31732c6ff986b58
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Fri Sep 5 15:31:15 2014 +0200
[loose parser] Be more careful about calling resetTo
It will try to eat whitespace, and can thus raise an unterminated comment exception
Issue #375
---
acorn_loose.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/acorn_loose.js b/acorn_loose.js
index 208c188..b3506b4 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -86,7 +86,7 @@
// Try to skip some text, based on the error message, and then continue
var msg = e.message, pos = e.raisedAt, replace = true;
if (/unterminated/i.test(msg)) {
- pos = lineEnd(e.pos);
+ pos = lineEnd(e.pos + 1);
if (/string/.test(msg)) {
replace = {start: e.pos, end: pos, type: tt.string, value: input.slice(e.pos + 1, pos)};
} else if (/regular expr/i.test(msg)) {
@@ -125,10 +125,18 @@
}
function resetTo(pos) {
- var ch = input.charAt(pos - 1);
- var reAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
- /[enwfd]/.test(ch) && /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(input.slice(pos - 10, pos));
- fetchToken.jumpTo(pos, reAllowed);
+ for (;;) {
+ try {
+ var ch = input.charAt(pos - 1);
+ var reAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
+ /[enwfd]/.test(ch) && /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(input.slice(pos - 10, pos));
+ return fetchToken.jumpTo(pos, reAllowed);
+ } catch(e) {
+ if (!(e instanceof SyntaxError && /unterminated comment/i.test(e.message))) throw e;
+ pos = lineEnd(e.pos + 1);
+ if (pos >= input.length) return;
+ }
+ }
}
function lookAhead(n) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list