Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shift-regexp-acceptor

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shift-regexp-acceptor - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

97

dist/index.js

@@ -68,3 +68,3 @@ 'use strict';

var INVALID_NAMED_BACKREFERENCE_SENTINEL = { INVALID_NAMED_BACKREFERENCE_SENTINE: true };
var INVALID_NAMED_BACKREFERENCE_SENTINEL = {};

@@ -86,3 +86,3 @@ function isIdentifierStart(ch) {

this.index = 0;
this.backreferences = [];
this.largestBackreference = 0;
this.backreferenceNames = [];

@@ -99,2 +99,9 @@ this.groupingNames = [];

}, {
key: 'backreference',
value: function backreference(ref) {
if (ref > this.largestBackreference) {
this.largestBackreference = ref;
}
}
}, {
key: 'nextCodePoint',

@@ -315,2 +322,7 @@ value: function nextCodePoint() {

if (state.unicode) {
if (state.largestBackreference > state.capturingGroups) {
return false;
}
}
if (state.groupingNames.length > 0 || state.unicode) {
var _iteratorNormalCompletion4 = true;

@@ -321,6 +333,6 @@ var _didIteratorError4 = false;

try {
for (var _iterator4 = state.backreferences[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var backreference = _step4.value;
for (var _iterator4 = state.backreferenceNames[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var backreferenceName = _step4.value;
if (backreference > state.capturingGroups) {
if (state.groupingNames.indexOf(backreferenceName) === -1) {
return false;

@@ -344,30 +356,2 @@ }

}
if (state.groupingNames.length > 0 || state.unicode) {
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = state.backreferenceNames[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var backreferenceName = _step5.value;
if (state.groupingNames.indexOf(backreferenceName) === -1) {
return false;
}
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
}
}

@@ -380,3 +364,3 @@ return accepted.matched;

var savedIndex = state.index;
var oldBackreferences = state.backreferences.slice(0);
var oldBackreference = state.largestBackreference;
var oldCapturingGroups = state.capturingGroups;

@@ -386,3 +370,3 @@ var val = func(state);

state.index = savedIndex;
state.backreferences = oldBackreferences;
state.largestBackreference = oldBackreference;
state.capturingGroups = oldCapturingGroups;

@@ -474,9 +458,9 @@ }

return function (state) {
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator6 = acceptors[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
var predicate = _step6.value;
for (var _iterator5 = acceptors[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var predicate = _step5.value;

@@ -489,12 +473,12 @@ var value = predicate(state);

} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return) {
_iterator6.return();
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
if (_didIteratorError5) {
throw _iteratorError5;
}

@@ -650,9 +634,12 @@ }

var acceptDecimalEscape = backtrackOnFailure(function (state) {
var firstDecimal = state.eatAny.apply(state, _toConsumableArray(decimalDigits.slice(1)));
var firstDecimal = state.eatAny.apply(state, _toConsumableArray(decimalDigits));
if (firstDecimal === null) {
return { matched: false };
}
if (firstDecimal === '0') {
return { matched: true };
}
// we also accept octal escapes here, but it is impossible to tell if it is a octal escape until all parsing is complete.
// octal escapes are handled in acceptCharacterEscape for classes
state.backreferences.push(parseInt(firstDecimal + (state.eatNaturalNumber() || '')));
state.backreference(parseInt(firstDecimal + (state.eatNaturalNumber() || '')));
return { matched: true };

@@ -859,7 +846,2 @@ });

}, function (subState) {
if (!subState.unicode) {
return { matched: false };
}
return acceptDecimalEscape(subState);
}, function (subState) {
return { matched: subState.unicode && !!subState.eat('-'), value: '-'.charCodeAt(0) };

@@ -875,3 +857,10 @@ }, backtrackOnFailure(function (subState) {

return { matched: true, value: character.charCodeAt(0) % 32 };
}), acceptCharacterClassEscape, acceptCharacterEscape);
}), acceptCharacterClassEscape, acceptCharacterEscape,
// We special-case `\k` because `acceptCharacterEscape` rejects `\k` unconditionally,
// deferring `\k` to acceptGroupNameBackreference, which is not called here.
// See also https://github.com/tc39/ecma262/issues/2037. This code takes the route of
// making it unconditionally legal, rather than legal only in the absence of a group name.
function (subState) {
return { matched: !subState.unicode && !!subState.eat('k'), value: 107 };
});

@@ -878,0 +867,0 @@ var acceptClassAtomNoDash = function acceptClassAtomNoDash(localState) {

{
"name": "shift-regexp-acceptor",
"version": "2.0.2",
"version": "2.0.3",
"description": "Regexp acceptor for ECMAScript 2018",

@@ -5,0 +5,0 @@ "author": "Shape Security",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc