Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '24.x'
- name: Authenticate to GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
Expand Down
56 changes: 36 additions & 20 deletions dist/esprima.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,24 @@ parseStatement: true, parseSourceElement: true */
};
}

function isImplicitOctalLiteral() {
var i, ch;

// Implicit octal, unless there is a non-octal digit.
// (Annex B.1.1 on Numeric Literals)
for (i = index + 1; i < length; ++i) {
ch = source[i];
if (ch === '8' || ch === '9') {
return false;
}
if (!isOctalDigit(ch)) {
return true;
}
}

return true;
}

function scanNumericLiteral() {
var number, start, ch;

Expand All @@ -857,12 +875,9 @@ parseStatement: true, parseSourceElement: true */
return scanHexLiteral(start);
}
if (isOctalDigit(ch)) {
return scanOctalLiteral(start);
}

// decimal number starts with '0' such as '09' is illegal.
if (ch && isDecimalDigit(ch.charCodeAt(0))) {
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
if (isImplicitOctalLiteral()) {
return scanOctalLiteral(start);
}
}
}

Expand Down Expand Up @@ -1260,7 +1275,7 @@ parseStatement: true, parseSourceElement: true */
}
return collectRegex();
}
if (prevToken.type === 'Keyword') {
if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
return collectRegex();
}
return scanPunctuator();
Expand Down Expand Up @@ -1945,7 +1960,8 @@ parseStatement: true, parseSourceElement: true */
}

function consumeSemicolon() {
var line;
var line, oldIndex = index, oldLineNumber = lineNumber,
oldLineStart = lineStart, oldLookahead = lookahead;

// Catch the very common case first: immediately a semicolon (U+003B).
if (source.charCodeAt(index) === 0x3B || match(';')) {
Expand All @@ -1956,6 +1972,10 @@ parseStatement: true, parseSourceElement: true */
line = lineNumber;
skipComment();
if (lineNumber !== line) {
index = oldIndex;
lineNumber = oldLineNumber;
lineStart = oldLineStart;
lookahead = oldLookahead;
return;
}

Expand Down Expand Up @@ -2266,14 +2286,11 @@ parseStatement: true, parseSourceElement: true */
}

function parseLeftHandSideExpressionAllowCall() {
var previousAllowIn, expr, args, property, startToken;
var expr, args, property, startToken, previousAllowIn = state.allowIn;

startToken = lookahead;

previousAllowIn = state.allowIn;
state.allowIn = true;
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
state.allowIn = previousAllowIn;

for (;;) {
if (match('.')) {
Expand All @@ -2290,18 +2307,18 @@ parseStatement: true, parseSourceElement: true */
}
delegate.markEnd(expr, startToken);
}
state.allowIn = previousAllowIn;

return expr;
}

function parseLeftHandSideExpression() {
var previousAllowIn, expr, property, startToken;
var expr, property, startToken;
assert(state.allowIn, 'callee of new expression always allow in keyword.');

startToken = lookahead;

previousAllowIn = state.allowIn;
expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression();
state.allowIn = previousAllowIn;

while (match('.') || match('[')) {
if (match('[')) {
Expand All @@ -2313,7 +2330,6 @@ parseStatement: true, parseSourceElement: true */
}
delegate.markEnd(expr, startToken);
}

return expr;
}

Expand Down Expand Up @@ -2816,7 +2832,7 @@ parseStatement: true, parseSourceElement: true */
}

function parseForStatement() {
var init, test, update, left, right, body, oldInIteration;
var init, test, update, left, right, body, oldInIteration, previousAllowIn = state.allowIn;

init = test = update = null;

Expand All @@ -2830,7 +2846,7 @@ parseStatement: true, parseSourceElement: true */
if (matchKeyword('var') || matchKeyword('let')) {
state.allowIn = false;
init = parseForVariableDeclaration();
state.allowIn = true;
state.allowIn = previousAllowIn;

if (init.declarations.length === 1 && matchKeyword('in')) {
lex();
Expand All @@ -2841,7 +2857,7 @@ parseStatement: true, parseSourceElement: true */
} else {
state.allowIn = false;
init = parseExpression();
state.allowIn = true;
state.allowIn = previousAllowIn;

if (matchKeyword('in')) {
// LeftHandSideExpression
Expand Down Expand Up @@ -3724,7 +3740,7 @@ parseStatement: true, parseSourceElement: true */
}

// Sync with *.json manifests.
exports.version = '1.2.2';
exports.version = '1.2.5';

exports.tokenize = tokenize;

Expand Down
Loading
Loading