🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

regjsparser

Package Overview
Dependencies
Maintainers
0
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regjsparser - npm Package Compare versions

Comparing version

to
0.11.2

8

package.json
{
"name": "regjsparser",
"version": "0.11.1",
"version": "0.11.2",
"author": "'Julian Viereck' <julian.viereck@gmail.com>",

@@ -8,7 +8,9 @@ "license": "BSD-2-Clause",

"types": "./parser.d.ts",
"bin": "bin/parser",
"bin": {
"regjsparser": "bin/parser"
},
"homepage": "https://github.com/jviereck/regjsparser",
"repository": {
"type": "git",
"url": "git@github.com:jviereck/regjsparser.git"
"url": "git+ssh://git@github.com/jviereck/regjsparser.git"
},

@@ -15,0 +17,0 @@ "scripts": {

@@ -570,6 +570,13 @@ // regjsparser

// Anchor
// Anchor Quantifier (see https://github.com/jviereck/regjsparser/issues/130)
// Atom
// Atom Quantifier
// Term (Annex B)::
// [~UnicodeMode] QuantifiableAssertion Quantifier (see https://github.com/jviereck/regjsparser/issues/130)
// [~UnicodeMode] ExtendedAtom Quantifier
// QuantifiableAssertion::
// (?= Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] )
// (?! Disjunction[~UnicodeMode, ~UnicodeSetsMode, ?NamedCaptureGroups] )
if (pos >= str.length || current('|') || current(')')) {

@@ -579,28 +586,43 @@ return null; /* Means: The term is empty */

var anchorOrAtom = parseAnchor();
var anchor = parseAnchor();
// If there is no Anchor, try to parse an atom.
if (!anchorOrAtom) {
var atom = parseAtomAndExtendedAtom();
var quantifier;
if (!atom) {
// Check if a quantifier is following. A quantifier without an atom
// is an error.
var pos_backup = pos
quantifier = parseQuantifier() || false;
if (quantifier) {
pos = pos_backup
bail('Expected atom');
if (anchor) {
var pos_backup = pos;
quantifier = parseQuantifier() || false;
if (quantifier) {
// Annex B
if (!isUnicodeMode && anchor.type === "group") {
quantifier.body = flattenBody(anchor);
// The quantifier contains the anchor. Therefore, the beginning of the
// quantifier range is given by the beginning of the anchor.
updateRawStart(quantifier, anchor.range[0]);
return quantifier;
}
pos = pos_backup;
bail("Expected atom");
}
return anchor;
}
// If no unicode flag, then try to parse ExtendedAtom -> ExtendedPatternCharacter.
// ExtendedPatternCharacter
var res;
if (!isUnicodeMode && (res = matchReg(/^\{/))) {
atom = createCharacter(res);
} else {
bail('Expected atom');
}
// If there is no Anchor, try to parse an atom.
var atom = parseAtomAndExtendedAtom();
var quantifier;
if (!atom) {
// Check if a quantifier is following. A quantifier without an atom
// is an error.
pos_backup = pos;
quantifier = parseQuantifier() || false;
if (quantifier) {
pos = pos_backup;
bail("Expected atom");
}
anchorOrAtom = atom;
// If no unicode flag, then try to parse ExtendedAtom -> ExtendedPatternCharacter.
// ExtendedPatternCharacter
var res;
if (!isUnicodeMode && (res = matchReg(/^\{/))) {
atom = createCharacter(res);
} else {
bail("Expected atom");
}
}

@@ -610,9 +632,7 @@

if (quantifier) {
var type = anchorOrAtom.type, behavior = anchorOrAtom.behavior;
var type = atom.type, behavior = atom.behavior;
if (
type === "group" &&
(behavior === "negativeLookbehind" ||
behavior === "lookbehind" ||
(isUnicodeMode &&
(behavior === "negativeLookahead" || behavior === "lookahead")))
behavior === "lookbehind")
) {

@@ -626,9 +646,9 @@ bail(

}
quantifier.body = flattenBody(anchorOrAtom);
quantifier.body = flattenBody(atom);
// The quantifier contains the atom. Therefore, the beginning of the
// quantifier range is given by the beginning of the atom.
updateRawStart(quantifier, anchorOrAtom.range[0]);
updateRawStart(quantifier, atom.range[0]);
return quantifier;
}
return anchorOrAtom;
return atom;
}

@@ -836,3 +856,3 @@

var disablingFlags;
if(match("-")){
if(match("-") && lookahead() !== ":"){
disablingFlags = matchReg(/^[sim]+/);

@@ -868,3 +888,3 @@ if (!disablingFlags) {

function parseUnicodeSurrogatePairEscape(firstEscape) {
function parseUnicodeSurrogatePairEscape(firstEscape, isUnicodeMode) {
if (isUnicodeMode) {

@@ -1036,4 +1056,2 @@ var first, second;

});
} else if (features.unicodeSet && hasUnicodeSetFlag && match('q{')) {
return parseClassStringDisjunction();
}

@@ -1051,3 +1069,3 @@ return false;

function parseRegExpUnicodeEscapeSequence() {
function parseRegExpUnicodeEscapeSequence(isUnicodeMode) {
var res;

@@ -1057,3 +1075,4 @@ if (res = matchReg(/^u([0-9a-fA-F]{4})/)) {

return parseUnicodeSurrogatePairEscape(
createEscaped('unicodeEscape', parseInt(res[1], 16), res[1], 2)
createEscaped('unicodeEscape', parseInt(res[1], 16), res[1], 2),
isUnicodeMode
);

@@ -1071,4 +1090,4 @@ } else if (isUnicodeMode && (res = matchReg(/^u\{([0-9a-fA-F]+)\}/))) {

// HexEscapeSequence
// UnicodeEscapeSequence
// IdentityEscape
// UnicodeEscapeSequence[?UnicodeMode]
// IdentityEscape[?UnicodeMode]

@@ -1094,3 +1113,3 @@ var res;

return createEscaped('hexadecimalEscape', parseInt(res[1], 16), res[1], 2);
} else if (res = parseRegExpUnicodeEscapeSequence()) {
} else if (res = parseRegExpUnicodeEscapeSequence(isUnicodeMode)) {
if (!res || res.codePoint > 0x10FFFF) {

@@ -1107,2 +1126,13 @@ bail('Invalid escape sequence', null, from, pos);

function parseIdentifierAtom(check) {
// RegExpIdentifierStart[UnicodeMode] ::
// IdentifierStartChar
// \ RegExpUnicodeEscapeSequence[+UnicodeMode]
// [~UnicodeMode] UnicodeLeadSurrogate UnicodeTrailSurrogate
//
// RegExpIdentifierPart[UnicodeMode] ::
// IdentifierPartChar
// \ RegExpUnicodeEscapeSequence[+UnicodeMode]
// [~UnicodeMode] UnicodeLeadSurrogate UnicodeTrailSurrogate
var ch = lookahead();

@@ -1112,3 +1142,3 @@ var from = pos;

incr();
var esc = parseRegExpUnicodeEscapeSequence();
var esc = parseRegExpUnicodeEscapeSequence(true);
if (!esc || !check(esc.codePoint)) {

@@ -1372,2 +1402,5 @@ bail('Invalid escape sequence', null, from, pos);

// \ ClassEscape
//
// ClassAtomNoDash (Annex B)::
// \ [lookahead = c]

@@ -1380,6 +1413,9 @@ var res;

if (!res) {
if (!isUnicodeMode && lookahead() == 'c') {
return createCharacter('\\');
}
bail('classEscape');
}
return parseUnicodeSurrogatePairEscape(res);
return parseUnicodeSurrogatePairEscape(res, isUnicodeMode);
}

@@ -1477,3 +1513,5 @@ }

// \ CharacterClassEscape[+U, +V]
if (res = parseClassEscape()) {
if (match('q{')) {
return parseClassStringDisjunction();
} else if (res = parseClassEscape()) {
start = res;

@@ -1480,0 +1518,0 @@ } else if (res = parseClassSetCharacterEscapedHelper()) {