Area restrita - Questionario
This commit is contained in:
Generated
Vendored
+12
-14
@@ -61,13 +61,10 @@ function parseCommaParts(str) {
|
||||
return parts;
|
||||
}
|
||||
|
||||
function expandTop(str, options) {
|
||||
function expandTop(str) {
|
||||
if (!str)
|
||||
return [];
|
||||
|
||||
options = options || {};
|
||||
var max = options.max == null ? Infinity : options.max;
|
||||
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
@@ -78,7 +75,7 @@ function expandTop(str, options) {
|
||||
str = '\\{\\}' + str.substr(2);
|
||||
}
|
||||
|
||||
return expand(escapeBraces(str), max, true).map(unescapeBraces);
|
||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||
}
|
||||
|
||||
function embrace(str) {
|
||||
@@ -95,7 +92,7 @@ function gte(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
|
||||
function expand(str, max, isTop) {
|
||||
function expand(str, isTop) {
|
||||
var expansions = [];
|
||||
|
||||
var m = balanced('{', '}', str);
|
||||
@@ -104,11 +101,11 @@ function expand(str, max, isTop) {
|
||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||
var pre = m.pre;
|
||||
var post = m.post.length
|
||||
? expand(m.post, max, false)
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
|
||||
if (/\$$/.test(m.pre)) {
|
||||
for (var k = 0; k < post.length && k < max; k++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre+ '{' + m.body + '}' + post[k];
|
||||
expansions.push(expansion);
|
||||
}
|
||||
@@ -121,7 +118,7 @@ function expand(str, max, isTop) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
return expand(str, max, true);
|
||||
return expand(str);
|
||||
}
|
||||
return [str];
|
||||
}
|
||||
@@ -133,7 +130,7 @@ function expand(str, max, isTop) {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand(n[0], max, false).map(embrace);
|
||||
n = expand(n[0], false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
@@ -151,7 +148,7 @@ function expand(str, max, isTop) {
|
||||
var y = numeric(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length)
|
||||
var incr = n.length == 3
|
||||
? Math.max(Math.abs(numeric(n[2])), 1)
|
||||
? Math.abs(numeric(n[2]))
|
||||
: 1;
|
||||
var test = lte;
|
||||
var reverse = y < x;
|
||||
@@ -163,7 +160,7 @@ function expand(str, max, isTop) {
|
||||
|
||||
N = [];
|
||||
|
||||
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
||||
for (var i = x; test(i, y); i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
@@ -188,12 +185,12 @@ function expand(str, max, isTop) {
|
||||
N = [];
|
||||
|
||||
for (var j = 0; j < n.length; j++) {
|
||||
N.push.apply(N, expand(n[j], max, false));
|
||||
N.push.apply(N, expand(n[j], false));
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length && expansions.length < max; k++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
@@ -203,3 +200,4 @@ function expand(str, max, isTop) {
|
||||
|
||||
return expansions;
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "brace-expansion",
|
||||
"description": "Brace expansion as known from sh/bash",
|
||||
"version": "2.1.1",
|
||||
"version": "2.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||
|
||||
Generated
Vendored
-37
@@ -7,43 +7,6 @@ This is the matching library used internally by npm.
|
||||
It works by converting glob expressions into JavaScript `RegExp`
|
||||
objects.
|
||||
|
||||
## Important Security Consideration!
|
||||
|
||||
> [!WARNING]
|
||||
> This library uses JavaScript regular expressions. Please read
|
||||
> the following warning carefully, and be thoughtful about what
|
||||
> you provide to this library in production systems.
|
||||
|
||||
_Any_ library in JavaScript that deals with matching string
|
||||
patterns using regular expressions will be subject to
|
||||
[ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS)
|
||||
if the pattern is generated using untrusted input.
|
||||
|
||||
Efforts have been made to mitigate risk as much as is feasible in
|
||||
such a library, providing maximum recursion depths and so forth,
|
||||
but these measures can only ultimately protect against accidents,
|
||||
not malice. A dedicated attacker can _always_ find patterns that
|
||||
cannot be defended against by a bash-compatible glob pattern
|
||||
matching system that uses JavaScript regular expressions.
|
||||
|
||||
To be extremely clear:
|
||||
|
||||
> [!WARNING]
|
||||
> **If you create a system where you take user input, and use
|
||||
> that input as the source of a Regular Expression pattern, in
|
||||
> this or any extant glob matcher in JavaScript, you will be
|
||||
> pwned.**
|
||||
|
||||
A future version of this library _may_ use a different matching
|
||||
algorithm which does not exhibit backtracking problems. If and
|
||||
when that happens, it will likely be a sweeping change, and those
|
||||
improvements will **not** be backported to legacy versions.
|
||||
|
||||
In the near term, it is not reasonable to continue to play
|
||||
whack-a-mole with security advisories, and so any future ReDoS
|
||||
reports will be considered "working as intended", and resolved
|
||||
entirely by this warning.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"assert-valid-pattern.js","sourceRoot":"","sources":["../../src/assert-valid-pattern.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAA;AAC7B,MAAM,kBAAkB,GAA2B,CACxD,OAAY,EACe,EAAE;IAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC,CAAA;AAVY,QAAA,kBAAkB,sBAU9B","sourcesContent":["const MAX_PATTERN_LENGTH = 1024 * 64\nexport const assertValidPattern: (pattern: any) => void = (\n pattern: any\n): asserts pattern is string => {\n if (typeof pattern !== 'string') {\n throw new TypeError('invalid pattern')\n }\n\n if (pattern.length > MAX_PATTERN_LENGTH) {\n throw new TypeError('pattern is too long')\n }\n}\n"]}
|
||||
{"version":3,"file":"assert-valid-pattern.js","sourceRoot":"","sources":["../../src/assert-valid-pattern.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAA;AAC7B,MAAM,kBAAkB,GAA2B,CACxD,OAAY,EACe,EAAE;IAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;KACvC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,kBAAkB,EAAE;QACvC,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAA;KAC3C;AACH,CAAC,CAAA;AAVY,QAAA,kBAAkB,sBAU9B","sourcesContent":["const MAX_PATTERN_LENGTH = 1024 * 64\nexport const assertValidPattern: (pattern: any) => void = (\n pattern: any\n): asserts pattern is string => {\n if (typeof pattern !== 'string') {\n throw new TypeError('invalid pattern')\n }\n\n if (pattern.length > MAX_PATTERN_LENGTH) {\n throw new TypeError('pattern is too long')\n }\n}\n"]}
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"A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AAE,WAAW,GAAG,IAAI,EACxB,MAAM,CAAC,EAAE,GAAG,EACZ,OAAO,GAAE,gBAAqB;IAahC,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAUlC;IAGD,QAAQ,IAAI,MAAM;IA+ClB,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;IAY/B,MAAM;IAgBN,OAAO,IAAI,OAAO;IAgBlB,KAAK,IAAI,OAAO;IAYhB,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM;IAKzB,KAAK,CAAC,MAAM,EAAE,GAAG;IAsIjB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAQ/D,WAAW,IAAI,QAAQ,GAAG,MAAM;IA2BhC,IAAI,OAAO,qBAEV;IAuED,cAAc,CACZ,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;CAiMjE"}
|
||||
Generated
Vendored
+24
-179
@@ -1,38 +1,11 @@
|
||||
"use strict";
|
||||
// parse a single path portion
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AST = void 0;
|
||||
const brace_expressions_js_1 = require("./brace-expressions.js");
|
||||
const unescape_js_1 = require("./unescape.js");
|
||||
const types = new Set(['!', '?', '+', '*', '@']);
|
||||
const isExtglobType = (c) => types.has(c);
|
||||
const isExtglobAST = (c) => isExtglobType(c.type);
|
||||
const adoptionMap = new Map([
|
||||
['!', ['@']],
|
||||
['?', ['?', '@']],
|
||||
['@', ['@']],
|
||||
['*', ['*', '+', '?', '@']],
|
||||
['+', ['+', '@']],
|
||||
]);
|
||||
const adoptionWithSpaceMap = new Map([
|
||||
['!', ['?']],
|
||||
['@', ['?']],
|
||||
['+', ['?', '*']],
|
||||
]);
|
||||
const adoptionAnyMap = new Map([
|
||||
['!', ['?', '@']],
|
||||
['?', ['?', '@']],
|
||||
['@', ['?', '@']],
|
||||
['*', ['*', '+', '?', '@']],
|
||||
['+', ['+', '@', '?', '*']],
|
||||
]);
|
||||
const usurpMap = new Map([
|
||||
['!', new Map([['!', '@']])],
|
||||
['?', new Map([['*', '*'], ['+', '*']])],
|
||||
['@', new Map([['!', '!'], ['?', '?'], ['@', '@'], ['*', '*'], ['+', '+']])],
|
||||
['+', new Map([['?', '*'], ['*', '*']])],
|
||||
]);
|
||||
// Patterns that get prepended to bind to the start of either the
|
||||
// entire string, or just a single path portion, to prevent dots
|
||||
// and/or traversal patterns, when needed.
|
||||
@@ -149,7 +122,7 @@ class AST {
|
||||
if (p === '')
|
||||
continue;
|
||||
/* c8 ignore start */
|
||||
if (typeof p !== 'string' && !(p instanceof _a && p.#parent === this)) {
|
||||
if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
|
||||
throw new Error('invalid part: ' + p);
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
@@ -181,7 +154,7 @@ class AST {
|
||||
const p = this.#parent;
|
||||
for (let i = 0; i < this.#parentIndex; i++) {
|
||||
const pp = p.#parts[i];
|
||||
if (!(pp instanceof _a && pp.type === '!')) {
|
||||
if (!(pp instanceof AST && pp.type === '!')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -209,14 +182,13 @@ class AST {
|
||||
this.push(part.clone(this));
|
||||
}
|
||||
clone(parent) {
|
||||
const c = new _a(this.type, parent);
|
||||
const c = new AST(this.type, parent);
|
||||
for (const p of this.#parts) {
|
||||
c.copyIn(p);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
static #parseAST(str, ast, pos, opt, extDepth) {
|
||||
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
||||
static #parseAST(str, ast, pos, opt) {
|
||||
let escaping = false;
|
||||
let inBrace = false;
|
||||
let braceStart = -1;
|
||||
@@ -253,15 +225,11 @@ class AST {
|
||||
acc += c;
|
||||
continue;
|
||||
}
|
||||
const doRecurse = !opt.noext &&
|
||||
isExtglobType(c) &&
|
||||
str.charAt(i) === '(' &&
|
||||
extDepth <= maxDepth;
|
||||
if (doRecurse) {
|
||||
if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
|
||||
ast.push(acc);
|
||||
acc = '';
|
||||
const ext = new _a(c, ast);
|
||||
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
||||
const ext = new AST(c, ast);
|
||||
i = AST.#parseAST(str, ext, i, opt);
|
||||
ast.push(ext);
|
||||
continue;
|
||||
}
|
||||
@@ -273,7 +241,7 @@ class AST {
|
||||
// some kind of extglob, pos is at the (
|
||||
// find the next | or )
|
||||
let i = pos + 1;
|
||||
let part = new _a(null, ast);
|
||||
let part = new AST(null, ast);
|
||||
const parts = [];
|
||||
let acc = '';
|
||||
while (i < str.length) {
|
||||
@@ -304,25 +272,19 @@ class AST {
|
||||
acc += c;
|
||||
continue;
|
||||
}
|
||||
const doRecurse = isExtglobType(c) &&
|
||||
str.charAt(i) === '(' &&
|
||||
/* c8 ignore start - the maxDepth is sufficient here */
|
||||
(extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
|
||||
/* c8 ignore stop */
|
||||
if (doRecurse) {
|
||||
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
||||
if (isExtglobType(c) && str.charAt(i) === '(') {
|
||||
part.push(acc);
|
||||
acc = '';
|
||||
const ext = new _a(c, part);
|
||||
const ext = new AST(c, part);
|
||||
part.push(ext);
|
||||
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
||||
i = AST.#parseAST(str, ext, i, opt);
|
||||
continue;
|
||||
}
|
||||
if (c === '|') {
|
||||
part.push(acc);
|
||||
acc = '';
|
||||
parts.push(part);
|
||||
part = new _a(null, ast);
|
||||
part = new AST(null, ast);
|
||||
continue;
|
||||
}
|
||||
if (c === ')') {
|
||||
@@ -344,115 +306,9 @@ class AST {
|
||||
ast.#parts = [str.substring(pos - 1)];
|
||||
return i;
|
||||
}
|
||||
#canAdoptWithSpace(child) {
|
||||
return this.#canAdopt(child, adoptionWithSpaceMap);
|
||||
}
|
||||
#canAdopt(child, map = adoptionMap) {
|
||||
if (!child ||
|
||||
typeof child !== 'object' ||
|
||||
child.type !== null ||
|
||||
child.#parts.length !== 1 ||
|
||||
this.type === null) {
|
||||
return false;
|
||||
}
|
||||
const gc = child.#parts[0];
|
||||
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
||||
return false;
|
||||
}
|
||||
return this.#canAdoptType(gc.type, map);
|
||||
}
|
||||
#canAdoptType(c, map = adoptionAnyMap) {
|
||||
return !!map.get(this.type)?.includes(c);
|
||||
}
|
||||
#adoptWithSpace(child, index) {
|
||||
const gc = child.#parts[0];
|
||||
const blank = new _a(null, gc, this.options);
|
||||
blank.#parts.push('');
|
||||
gc.push(blank);
|
||||
this.#adopt(child, index);
|
||||
}
|
||||
#adopt(child, index) {
|
||||
const gc = child.#parts[0];
|
||||
this.#parts.splice(index, 1, ...gc.#parts);
|
||||
for (const p of gc.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#parent = this;
|
||||
}
|
||||
this.#toString = undefined;
|
||||
}
|
||||
#canUsurpType(c) {
|
||||
const m = usurpMap.get(this.type);
|
||||
return !!(m?.has(c));
|
||||
}
|
||||
#canUsurp(child) {
|
||||
if (!child ||
|
||||
typeof child !== 'object' ||
|
||||
child.type !== null ||
|
||||
child.#parts.length !== 1 ||
|
||||
this.type === null ||
|
||||
this.#parts.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
const gc = child.#parts[0];
|
||||
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
||||
return false;
|
||||
}
|
||||
return this.#canUsurpType(gc.type);
|
||||
}
|
||||
#usurp(child) {
|
||||
const m = usurpMap.get(this.type);
|
||||
const gc = child.#parts[0];
|
||||
const nt = m?.get(gc.type);
|
||||
/* c8 ignore start - impossible */
|
||||
if (!nt)
|
||||
return false;
|
||||
/* c8 ignore stop */
|
||||
this.#parts = gc.#parts;
|
||||
for (const p of this.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#parent = this;
|
||||
}
|
||||
this.type = nt;
|
||||
this.#toString = undefined;
|
||||
this.#emptyExt = false;
|
||||
}
|
||||
#flatten() {
|
||||
if (!isExtglobAST(this)) {
|
||||
for (const p of this.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#flatten();
|
||||
}
|
||||
}
|
||||
else {
|
||||
let iterations = 0;
|
||||
let done = false;
|
||||
do {
|
||||
done = true;
|
||||
for (let i = 0; i < this.#parts.length; i++) {
|
||||
const c = this.#parts[i];
|
||||
if (typeof c === 'object') {
|
||||
c.#flatten();
|
||||
if (this.#canAdopt(c)) {
|
||||
done = false;
|
||||
this.#adopt(c, i);
|
||||
}
|
||||
else if (this.#canAdoptWithSpace(c)) {
|
||||
done = false;
|
||||
this.#adoptWithSpace(c, i);
|
||||
}
|
||||
else if (this.#canUsurp(c)) {
|
||||
done = false;
|
||||
this.#usurp(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!done && ++iterations < 10);
|
||||
}
|
||||
this.#toString = undefined;
|
||||
}
|
||||
static fromGlob(pattern, options = {}) {
|
||||
const ast = new _a(null, undefined, options);
|
||||
_a.#parseAST(pattern, ast, 0, options, 0);
|
||||
const ast = new AST(null, undefined, options);
|
||||
AST.#parseAST(pattern, ast, 0, options);
|
||||
return ast;
|
||||
}
|
||||
// returns the regular expression if there's magic, or the unescaped
|
||||
@@ -556,16 +412,14 @@ class AST {
|
||||
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
||||
toRegExpSource(allowDot) {
|
||||
const dot = allowDot ?? !!this.#options.dot;
|
||||
if (this.#root === this) {
|
||||
this.#flatten();
|
||||
if (this.#root === this)
|
||||
this.#fillNegs();
|
||||
}
|
||||
if (!isExtglobAST(this)) {
|
||||
if (!this.type) {
|
||||
const noEmpty = this.isStart() && this.isEnd();
|
||||
const src = this.#parts
|
||||
.map(p => {
|
||||
const [re, _, hasMagic, uflag] = typeof p === 'string'
|
||||
? _a.#parseGlob(p, this.#hasMagic, noEmpty)
|
||||
? AST.#parseGlob(p, this.#hasMagic, noEmpty)
|
||||
: p.toRegExpSource(allowDot);
|
||||
this.#hasMagic = this.#hasMagic || hasMagic;
|
||||
this.#uflag = this.#uflag || uflag;
|
||||
@@ -624,10 +478,9 @@ class AST {
|
||||
// invalid extglob, has to at least be *something* present, if it's
|
||||
// the entire path portion.
|
||||
const s = this.toString();
|
||||
const me = this;
|
||||
me.#parts = [s];
|
||||
me.type = null;
|
||||
me.#hasMagic = undefined;
|
||||
this.#parts = [s];
|
||||
this.type = null;
|
||||
this.#hasMagic = undefined;
|
||||
return [s, (0, unescape_js_1.unescape)(this.toString()), false, false];
|
||||
}
|
||||
// XXX abstract out this map method
|
||||
@@ -691,14 +544,11 @@ class AST {
|
||||
let escaping = false;
|
||||
let re = '';
|
||||
let uflag = false;
|
||||
// multiple stars that aren't globstars coalesce into one *
|
||||
let inStar = false;
|
||||
for (let i = 0; i < glob.length; i++) {
|
||||
const c = glob.charAt(i);
|
||||
if (escaping) {
|
||||
escaping = false;
|
||||
re += (reSpecials.has(c) ? '\\' : '') + c;
|
||||
inStar = false;
|
||||
continue;
|
||||
}
|
||||
if (c === '\\') {
|
||||
@@ -717,21 +567,17 @@ class AST {
|
||||
uflag = uflag || needUflag;
|
||||
i += consumed - 1;
|
||||
hasMagic = hasMagic || magic;
|
||||
inStar = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c === '*') {
|
||||
if (inStar)
|
||||
continue;
|
||||
inStar = true;
|
||||
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
||||
if (noEmpty && glob === '*')
|
||||
re += starNoEmpty;
|
||||
else
|
||||
re += star;
|
||||
hasMagic = true;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
inStar = false;
|
||||
}
|
||||
if (c === '?') {
|
||||
re += qmark;
|
||||
hasMagic = true;
|
||||
@@ -743,5 +589,4 @@ class AST {
|
||||
}
|
||||
}
|
||||
exports.AST = AST;
|
||||
_a = AST;
|
||||
//# sourceMappingURL=ast.js.map
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"brace-expressions.d.ts","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;CAClB,CAAA;AAQD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,KACf,gBA6HF,CAAA"}
|
||||
{"version":3,"file":"brace-expressions.d.ts","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;CAClB,CAAA;AAQD,eAAO,MAAM,UAAU,SACf,MAAM,YACF,MAAM,qBA8HjB,CAAA"}
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -8,5 +8,5 @@ import { MinimatchOptions } from './index.js';
|
||||
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
||||
* not interpreted as a magic character, but instead as a path separator.
|
||||
*/
|
||||
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, "windowsPathsNoEscape">) => string;
|
||||
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>) => string;
|
||||
//# sourceMappingURL=escape.d.ts.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GACjB,GAAG,MAAM,EACT,4BAEG,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,WAQvD,CAAA"}
|
||||
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MACd,MAAM,8BAGN,KAAK,gBAAgB,EAAE,sBAAsB,CAAC,WAQlD,CAAA"}
|
||||
Generated
Vendored
-4
@@ -21,8 +21,6 @@ export interface MinimatchOptions {
|
||||
optimizationLevel?: number;
|
||||
platform?: Platform;
|
||||
windowsNoMagicRoot?: boolean;
|
||||
maxGlobstarRecursion?: number;
|
||||
maxExtglobRecursion?: number;
|
||||
}
|
||||
export declare const minimatch: {
|
||||
(p: string, pattern: string, options?: MinimatchOptions): boolean;
|
||||
@@ -53,7 +51,6 @@ export type MMRegExp = RegExp & {
|
||||
export type ParseReturnFiltered = string | MMRegExp | typeof GLOBSTAR;
|
||||
export type ParseReturn = ParseReturnFiltered | false;
|
||||
export declare class Minimatch {
|
||||
#private;
|
||||
options: MinimatchOptions;
|
||||
set: ParseReturnFiltered[][];
|
||||
pattern: string;
|
||||
@@ -70,7 +67,6 @@ export declare class Minimatch {
|
||||
isWindows: boolean;
|
||||
platform: Platform;
|
||||
windowsNoMagicRoot: boolean;
|
||||
maxGlobstarRecursion: number;
|
||||
regexp: false | null | MMRegExp;
|
||||
constructor(pattern: string, options?: MinimatchOptions);
|
||||
hasMagic(): boolean;
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,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CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB;CAGtC;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
|
||||
Generated
Vendored
+120
-126
@@ -205,13 +205,11 @@ class Minimatch {
|
||||
isWindows;
|
||||
platform;
|
||||
windowsNoMagicRoot;
|
||||
maxGlobstarRecursion;
|
||||
regexp;
|
||||
constructor(pattern, options = {}) {
|
||||
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
||||
options = options || {};
|
||||
this.options = options;
|
||||
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
||||
this.pattern = pattern;
|
||||
this.platform = options.platform || defaultPlatform;
|
||||
this.isWindows = this.platform === 'win32';
|
||||
@@ -611,8 +609,7 @@ class Minimatch {
|
||||
// out of pattern, then that's fine, as long as all
|
||||
// the parts match.
|
||||
matchOne(file, pattern, partial = false) {
|
||||
let fileStartIndex = 0;
|
||||
let patternStartIndex = 0;
|
||||
const options = this.options;
|
||||
// UNC paths like //?/X:/... can match X:/... and vice versa
|
||||
// Drive letters in absolute drive or unc paths are always compared
|
||||
// case-insensitively.
|
||||
@@ -633,14 +630,15 @@ class Minimatch {
|
||||
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
||||
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
||||
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
||||
const [fd, pd] = [
|
||||
file[fdi],
|
||||
pattern[pdi],
|
||||
];
|
||||
const [fd, pd] = [file[fdi], pattern[pdi]];
|
||||
if (fd.toLowerCase() === pd.toLowerCase()) {
|
||||
pattern[pdi] = fd;
|
||||
patternStartIndex = pdi;
|
||||
fileStartIndex = fdi;
|
||||
if (pdi > fdi) {
|
||||
pattern = pattern.slice(pdi);
|
||||
}
|
||||
else if (fdi > pdi) {
|
||||
file = file.slice(fdi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -650,127 +648,102 @@ class Minimatch {
|
||||
if (optimizationLevel >= 2) {
|
||||
file = this.levelTwoFileOptimize(file);
|
||||
}
|
||||
if (pattern.includes(exports.GLOBSTAR)) {
|
||||
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
||||
}
|
||||
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
||||
}
|
||||
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
||||
const firstgs = pattern.indexOf(exports.GLOBSTAR, patternIndex);
|
||||
const lastgs = pattern.lastIndexOf(exports.GLOBSTAR);
|
||||
const [head, body, tail] = partial ? [
|
||||
pattern.slice(patternIndex, firstgs),
|
||||
pattern.slice(firstgs + 1),
|
||||
[],
|
||||
] : [
|
||||
pattern.slice(patternIndex, firstgs),
|
||||
pattern.slice(firstgs + 1, lastgs),
|
||||
pattern.slice(lastgs + 1),
|
||||
];
|
||||
if (head.length) {
|
||||
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
||||
if (!this.#matchOne(fileHead, head, partial, 0, 0))
|
||||
return false;
|
||||
fileIndex += head.length;
|
||||
}
|
||||
let fileTailMatch = 0;
|
||||
if (tail.length) {
|
||||
if (tail.length + fileIndex > file.length)
|
||||
return false;
|
||||
let tailStart = file.length - tail.length;
|
||||
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
||||
fileTailMatch = tail.length;
|
||||
}
|
||||
else {
|
||||
if (file[file.length - 1] !== '' ||
|
||||
fileIndex + tail.length === file.length) {
|
||||
return false;
|
||||
}
|
||||
tailStart--;
|
||||
if (!this.#matchOne(file, tail, partial, tailStart, 0))
|
||||
return false;
|
||||
fileTailMatch = tail.length + 1;
|
||||
}
|
||||
}
|
||||
if (!body.length) {
|
||||
let sawSome = !!fileTailMatch;
|
||||
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
||||
const f = String(file[i]);
|
||||
sawSome = true;
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return partial || sawSome;
|
||||
}
|
||||
const bodySegments = [[[], 0]];
|
||||
let currentBody = bodySegments[0];
|
||||
let nonGsParts = 0;
|
||||
const nonGsPartsSums = [0];
|
||||
for (const b of body) {
|
||||
if (b === exports.GLOBSTAR) {
|
||||
nonGsPartsSums.push(nonGsParts);
|
||||
currentBody = [[], 0];
|
||||
bodySegments.push(currentBody);
|
||||
}
|
||||
else {
|
||||
currentBody[0].push(b);
|
||||
nonGsParts++;
|
||||
}
|
||||
}
|
||||
let i = bodySegments.length - 1;
|
||||
const fileLength = file.length - fileTailMatch;
|
||||
for (const b of bodySegments) {
|
||||
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
||||
}
|
||||
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
||||
}
|
||||
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
||||
const bs = bodySegments[bodyIndex];
|
||||
if (!bs) {
|
||||
for (let i = fileIndex; i < file.length; i++) {
|
||||
sawTail = true;
|
||||
const f = file[i];
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return sawTail;
|
||||
}
|
||||
const [body, after] = bs;
|
||||
while (fileIndex <= after) {
|
||||
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
||||
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
||||
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
||||
if (sub !== false)
|
||||
return sub;
|
||||
}
|
||||
const f = file[fileIndex];
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
fileIndex++;
|
||||
}
|
||||
return partial || null;
|
||||
}
|
||||
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
||||
let fi;
|
||||
let pi;
|
||||
let pl;
|
||||
let fl;
|
||||
for (fi = fileIndex, pi = patternIndex,
|
||||
fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
||||
this.debug('matchOne', this, { file, pattern });
|
||||
this.debug('matchOne', file.length, pattern.length);
|
||||
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
||||
this.debug('matchOne loop');
|
||||
let p = pattern[pi];
|
||||
let f = file[fi];
|
||||
var p = pattern[pi];
|
||||
var f = file[fi];
|
||||
this.debug(pattern, p, f);
|
||||
// should be impossible.
|
||||
// some invalid regexp stuff in the set.
|
||||
/* c8 ignore start */
|
||||
if (p === false || p === exports.GLOBSTAR)
|
||||
if (p === false) {
|
||||
return false;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
if (p === exports.GLOBSTAR) {
|
||||
this.debug('GLOBSTAR', [pattern, p, f]);
|
||||
// "**"
|
||||
// a/**/b/**/c would match the following:
|
||||
// a/b/x/y/z/c
|
||||
// a/x/y/z/b/c
|
||||
// a/b/x/b/x/c
|
||||
// a/b/c
|
||||
// To do this, take the rest of the pattern after
|
||||
// the **, and see if it would match the file remainder.
|
||||
// If so, return success.
|
||||
// If not, the ** "swallows" a segment, and try again.
|
||||
// This is recursively awful.
|
||||
//
|
||||
// a/**/b/**/c matching a/b/x/y/z/c
|
||||
// - a matches a
|
||||
// - doublestar
|
||||
// - matchOne(b/x/y/z/c, b/**/c)
|
||||
// - b matches b
|
||||
// - doublestar
|
||||
// - matchOne(x/y/z/c, c) -> no
|
||||
// - matchOne(y/z/c, c) -> no
|
||||
// - matchOne(z/c, c) -> no
|
||||
// - matchOne(c, c) yes, hit
|
||||
var fr = fi;
|
||||
var pr = pi + 1;
|
||||
if (pr === pl) {
|
||||
this.debug('** at the end');
|
||||
// a ** at the end will just swallow the rest.
|
||||
// We have found a match.
|
||||
// however, it will not swallow /.x, unless
|
||||
// options.dot is set.
|
||||
// . and .. are *never* matched by **, for explosively
|
||||
// exponential reasons.
|
||||
for (; fi < fl; fi++) {
|
||||
if (file[fi] === '.' ||
|
||||
file[fi] === '..' ||
|
||||
(!options.dot && file[fi].charAt(0) === '.'))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// ok, let's see if we can swallow whatever we can.
|
||||
while (fr < fl) {
|
||||
var swallowee = file[fr];
|
||||
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
||||
// XXX remove this slice. Just pass the start index.
|
||||
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
||||
this.debug('globstar found match!', fr, fl, swallowee);
|
||||
// found a match.
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// can't swallow "." or ".." ever.
|
||||
// can only swallow ".foo" when explicitly asked.
|
||||
if (swallowee === '.' ||
|
||||
swallowee === '..' ||
|
||||
(!options.dot && swallowee.charAt(0) === '.')) {
|
||||
this.debug('dot detected!', file, fr, pattern, pr);
|
||||
break;
|
||||
}
|
||||
// ** swallows a segment, and continue.
|
||||
this.debug('globstar swallow a segment, and continue');
|
||||
fr++;
|
||||
}
|
||||
}
|
||||
// no match was found.
|
||||
// However, in partial mode, we can't say this is necessarily over.
|
||||
/* c8 ignore start */
|
||||
if (partial) {
|
||||
// ran out of file
|
||||
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
||||
if (fr === fl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
return false;
|
||||
}
|
||||
// something other than **
|
||||
// non-magic patterns just have to match exactly
|
||||
// patterns with magic have been turned into regexps.
|
||||
let hit;
|
||||
if (typeof p === 'string') {
|
||||
hit = f === p;
|
||||
@@ -783,17 +756,38 @@ class Minimatch {
|
||||
if (!hit)
|
||||
return false;
|
||||
}
|
||||
// Note: ending in / means that we'll get a final ""
|
||||
// at the end of the pattern. This can only match a
|
||||
// corresponding "" at the end of the file.
|
||||
// If the file ends in /, then it can only match a
|
||||
// a pattern that ends in /, unless the pattern just
|
||||
// doesn't have any more for it. But, a/b/ should *not*
|
||||
// match "a/b/*", even though "" matches against the
|
||||
// [^/]*? pattern, except in partial mode, where it might
|
||||
// simply not be reached yet.
|
||||
// However, a/b/ should still satisfy a/*
|
||||
// now either we fell off the end of the pattern, or we're done.
|
||||
if (fi === fl && pi === pl) {
|
||||
// ran out of pattern and filename at the same time.
|
||||
// an exact hit!
|
||||
return true;
|
||||
}
|
||||
else if (fi === fl) {
|
||||
// ran out of file, but still had pattern left.
|
||||
// this is ok if we're doing the match as part of
|
||||
// a glob fs traversal.
|
||||
return partial;
|
||||
}
|
||||
else if (pi === pl) {
|
||||
// ran out of pattern, still have file left.
|
||||
// this is only acceptable if we're on the very last
|
||||
// empty segment of a file with a trailing slash.
|
||||
// a/* should match a/b/
|
||||
return fi === fl - 1 && file[fi] === '';
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else {
|
||||
// should be unreachable.
|
||||
throw new Error('wtf?');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch/dist/commonjs/unescape.d.ts
Generated
Vendored
+1
-1
@@ -13,5 +13,5 @@ import { MinimatchOptions } from './index.js';
|
||||
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
||||
* or unescaped.
|
||||
*/
|
||||
export declare const unescape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, "windowsPathsNoEscape">) => string;
|
||||
export declare const unescape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>) => string;
|
||||
//# sourceMappingURL=unescape.d.ts.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,EACT,4BAEG,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,WAKvD,CAAA"}
|
||||
{"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,MAChB,MAAM,8BAGN,KAAK,gBAAgB,EAAE,sBAAsB,CAAC,WAKlD,CAAA"}
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"assert-valid-pattern.js","sourceRoot":"","sources":["../../src/assert-valid-pattern.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAA;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAA2B,CACxD,OAAY,EACe,EAAE;IAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC,CAAA","sourcesContent":["const MAX_PATTERN_LENGTH = 1024 * 64\nexport const assertValidPattern: (pattern: any) => void = (\n pattern: any\n): asserts pattern is string => {\n if (typeof pattern !== 'string') {\n throw new TypeError('invalid pattern')\n }\n\n if (pattern.length > MAX_PATTERN_LENGTH) {\n throw new TypeError('pattern is too long')\n }\n}\n"]}
|
||||
{"version":3,"file":"assert-valid-pattern.js","sourceRoot":"","sources":["../../src/assert-valid-pattern.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAA;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAA2B,CACxD,OAAY,EACe,EAAE;IAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;KACvC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,kBAAkB,EAAE;QACvC,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAA;KAC3C;AACH,CAAC,CAAA","sourcesContent":["const MAX_PATTERN_LENGTH = 1024 * 64\nexport const assertValidPattern: (pattern: any) => void = (\n pattern: any\n): asserts pattern is string => {\n if (typeof pattern !== 'string') {\n throw new TypeError('invalid pattern')\n }\n\n if (pattern.length > MAX_PATTERN_LENGTH) {\n throw new TypeError('pattern is too long')\n }\n}\n"]}
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAwCvD,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAiErD,qBAAa,GAAG;;IACd,IAAI,EAAE,WAAW,GAAG,IAAI,CAAA;gBAiBtB,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,MAAM,CAAC,EAAE,GAAG,EACZ,OAAO,GAAE,gBAAqB;IAahC,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAUlC;IAGD,QAAQ,IAAI,MAAM;IA+ClB,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;IAY/B,MAAM;IAgBN,OAAO,IAAI,OAAO;IAgBlB,KAAK,IAAI,OAAO;IAYhB,MA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CACZ,QAAQ,CAAC,EAAE,OAAO,GACjB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;CAiMjE"}
|
||||
Generated
Vendored
+24
-179
@@ -1,35 +1,8 @@
|
||||
// parse a single path portion
|
||||
var _a;
|
||||
import { parseClass } from './brace-expressions.js';
|
||||
import { unescape } from './unescape.js';
|
||||
const types = new Set(['!', '?', '+', '*', '@']);
|
||||
const isExtglobType = (c) => types.has(c);
|
||||
const isExtglobAST = (c) => isExtglobType(c.type);
|
||||
const adoptionMap = new Map([
|
||||
['!', ['@']],
|
||||
['?', ['?', '@']],
|
||||
['@', ['@']],
|
||||
['*', ['*', '+', '?', '@']],
|
||||
['+', ['+', '@']],
|
||||
]);
|
||||
const adoptionWithSpaceMap = new Map([
|
||||
['!', ['?']],
|
||||
['@', ['?']],
|
||||
['+', ['?', '*']],
|
||||
]);
|
||||
const adoptionAnyMap = new Map([
|
||||
['!', ['?', '@']],
|
||||
['?', ['?', '@']],
|
||||
['@', ['?', '@']],
|
||||
['*', ['*', '+', '?', '@']],
|
||||
['+', ['+', '@', '?', '*']],
|
||||
]);
|
||||
const usurpMap = new Map([
|
||||
['!', new Map([['!', '@']])],
|
||||
['?', new Map([['*', '*'], ['+', '*']])],
|
||||
['@', new Map([['!', '!'], ['?', '?'], ['@', '@'], ['*', '*'], ['+', '+']])],
|
||||
['+', new Map([['?', '*'], ['*', '*']])],
|
||||
]);
|
||||
// Patterns that get prepended to bind to the start of either the
|
||||
// entire string, or just a single path portion, to prevent dots
|
||||
// and/or traversal patterns, when needed.
|
||||
@@ -146,7 +119,7 @@ export class AST {
|
||||
if (p === '')
|
||||
continue;
|
||||
/* c8 ignore start */
|
||||
if (typeof p !== 'string' && !(p instanceof _a && p.#parent === this)) {
|
||||
if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
|
||||
throw new Error('invalid part: ' + p);
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
@@ -178,7 +151,7 @@ export class AST {
|
||||
const p = this.#parent;
|
||||
for (let i = 0; i < this.#parentIndex; i++) {
|
||||
const pp = p.#parts[i];
|
||||
if (!(pp instanceof _a && pp.type === '!')) {
|
||||
if (!(pp instanceof AST && pp.type === '!')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -206,14 +179,13 @@ export class AST {
|
||||
this.push(part.clone(this));
|
||||
}
|
||||
clone(parent) {
|
||||
const c = new _a(this.type, parent);
|
||||
const c = new AST(this.type, parent);
|
||||
for (const p of this.#parts) {
|
||||
c.copyIn(p);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
static #parseAST(str, ast, pos, opt, extDepth) {
|
||||
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
||||
static #parseAST(str, ast, pos, opt) {
|
||||
let escaping = false;
|
||||
let inBrace = false;
|
||||
let braceStart = -1;
|
||||
@@ -250,15 +222,11 @@ export class AST {
|
||||
acc += c;
|
||||
continue;
|
||||
}
|
||||
const doRecurse = !opt.noext &&
|
||||
isExtglobType(c) &&
|
||||
str.charAt(i) === '(' &&
|
||||
extDepth <= maxDepth;
|
||||
if (doRecurse) {
|
||||
if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
|
||||
ast.push(acc);
|
||||
acc = '';
|
||||
const ext = new _a(c, ast);
|
||||
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
||||
const ext = new AST(c, ast);
|
||||
i = AST.#parseAST(str, ext, i, opt);
|
||||
ast.push(ext);
|
||||
continue;
|
||||
}
|
||||
@@ -270,7 +238,7 @@ export class AST {
|
||||
// some kind of extglob, pos is at the (
|
||||
// find the next | or )
|
||||
let i = pos + 1;
|
||||
let part = new _a(null, ast);
|
||||
let part = new AST(null, ast);
|
||||
const parts = [];
|
||||
let acc = '';
|
||||
while (i < str.length) {
|
||||
@@ -301,25 +269,19 @@ export class AST {
|
||||
acc += c;
|
||||
continue;
|
||||
}
|
||||
const doRecurse = isExtglobType(c) &&
|
||||
str.charAt(i) === '(' &&
|
||||
/* c8 ignore start - the maxDepth is sufficient here */
|
||||
(extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
|
||||
/* c8 ignore stop */
|
||||
if (doRecurse) {
|
||||
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
||||
if (isExtglobType(c) && str.charAt(i) === '(') {
|
||||
part.push(acc);
|
||||
acc = '';
|
||||
const ext = new _a(c, part);
|
||||
const ext = new AST(c, part);
|
||||
part.push(ext);
|
||||
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
||||
i = AST.#parseAST(str, ext, i, opt);
|
||||
continue;
|
||||
}
|
||||
if (c === '|') {
|
||||
part.push(acc);
|
||||
acc = '';
|
||||
parts.push(part);
|
||||
part = new _a(null, ast);
|
||||
part = new AST(null, ast);
|
||||
continue;
|
||||
}
|
||||
if (c === ')') {
|
||||
@@ -341,115 +303,9 @@ export class AST {
|
||||
ast.#parts = [str.substring(pos - 1)];
|
||||
return i;
|
||||
}
|
||||
#canAdoptWithSpace(child) {
|
||||
return this.#canAdopt(child, adoptionWithSpaceMap);
|
||||
}
|
||||
#canAdopt(child, map = adoptionMap) {
|
||||
if (!child ||
|
||||
typeof child !== 'object' ||
|
||||
child.type !== null ||
|
||||
child.#parts.length !== 1 ||
|
||||
this.type === null) {
|
||||
return false;
|
||||
}
|
||||
const gc = child.#parts[0];
|
||||
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
||||
return false;
|
||||
}
|
||||
return this.#canAdoptType(gc.type, map);
|
||||
}
|
||||
#canAdoptType(c, map = adoptionAnyMap) {
|
||||
return !!map.get(this.type)?.includes(c);
|
||||
}
|
||||
#adoptWithSpace(child, index) {
|
||||
const gc = child.#parts[0];
|
||||
const blank = new _a(null, gc, this.options);
|
||||
blank.#parts.push('');
|
||||
gc.push(blank);
|
||||
this.#adopt(child, index);
|
||||
}
|
||||
#adopt(child, index) {
|
||||
const gc = child.#parts[0];
|
||||
this.#parts.splice(index, 1, ...gc.#parts);
|
||||
for (const p of gc.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#parent = this;
|
||||
}
|
||||
this.#toString = undefined;
|
||||
}
|
||||
#canUsurpType(c) {
|
||||
const m = usurpMap.get(this.type);
|
||||
return !!(m?.has(c));
|
||||
}
|
||||
#canUsurp(child) {
|
||||
if (!child ||
|
||||
typeof child !== 'object' ||
|
||||
child.type !== null ||
|
||||
child.#parts.length !== 1 ||
|
||||
this.type === null ||
|
||||
this.#parts.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
const gc = child.#parts[0];
|
||||
if (!gc || typeof gc !== 'object' || gc.type === null) {
|
||||
return false;
|
||||
}
|
||||
return this.#canUsurpType(gc.type);
|
||||
}
|
||||
#usurp(child) {
|
||||
const m = usurpMap.get(this.type);
|
||||
const gc = child.#parts[0];
|
||||
const nt = m?.get(gc.type);
|
||||
/* c8 ignore start - impossible */
|
||||
if (!nt)
|
||||
return false;
|
||||
/* c8 ignore stop */
|
||||
this.#parts = gc.#parts;
|
||||
for (const p of this.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#parent = this;
|
||||
}
|
||||
this.type = nt;
|
||||
this.#toString = undefined;
|
||||
this.#emptyExt = false;
|
||||
}
|
||||
#flatten() {
|
||||
if (!isExtglobAST(this)) {
|
||||
for (const p of this.#parts) {
|
||||
if (typeof p === 'object')
|
||||
p.#flatten();
|
||||
}
|
||||
}
|
||||
else {
|
||||
let iterations = 0;
|
||||
let done = false;
|
||||
do {
|
||||
done = true;
|
||||
for (let i = 0; i < this.#parts.length; i++) {
|
||||
const c = this.#parts[i];
|
||||
if (typeof c === 'object') {
|
||||
c.#flatten();
|
||||
if (this.#canAdopt(c)) {
|
||||
done = false;
|
||||
this.#adopt(c, i);
|
||||
}
|
||||
else if (this.#canAdoptWithSpace(c)) {
|
||||
done = false;
|
||||
this.#adoptWithSpace(c, i);
|
||||
}
|
||||
else if (this.#canUsurp(c)) {
|
||||
done = false;
|
||||
this.#usurp(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!done && ++iterations < 10);
|
||||
}
|
||||
this.#toString = undefined;
|
||||
}
|
||||
static fromGlob(pattern, options = {}) {
|
||||
const ast = new _a(null, undefined, options);
|
||||
_a.#parseAST(pattern, ast, 0, options, 0);
|
||||
const ast = new AST(null, undefined, options);
|
||||
AST.#parseAST(pattern, ast, 0, options);
|
||||
return ast;
|
||||
}
|
||||
// returns the regular expression if there's magic, or the unescaped
|
||||
@@ -553,16 +409,14 @@ export class AST {
|
||||
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
||||
toRegExpSource(allowDot) {
|
||||
const dot = allowDot ?? !!this.#options.dot;
|
||||
if (this.#root === this) {
|
||||
this.#flatten();
|
||||
if (this.#root === this)
|
||||
this.#fillNegs();
|
||||
}
|
||||
if (!isExtglobAST(this)) {
|
||||
if (!this.type) {
|
||||
const noEmpty = this.isStart() && this.isEnd();
|
||||
const src = this.#parts
|
||||
.map(p => {
|
||||
const [re, _, hasMagic, uflag] = typeof p === 'string'
|
||||
? _a.#parseGlob(p, this.#hasMagic, noEmpty)
|
||||
? AST.#parseGlob(p, this.#hasMagic, noEmpty)
|
||||
: p.toRegExpSource(allowDot);
|
||||
this.#hasMagic = this.#hasMagic || hasMagic;
|
||||
this.#uflag = this.#uflag || uflag;
|
||||
@@ -621,10 +475,9 @@ export class AST {
|
||||
// invalid extglob, has to at least be *something* present, if it's
|
||||
// the entire path portion.
|
||||
const s = this.toString();
|
||||
const me = this;
|
||||
me.#parts = [s];
|
||||
me.type = null;
|
||||
me.#hasMagic = undefined;
|
||||
this.#parts = [s];
|
||||
this.type = null;
|
||||
this.#hasMagic = undefined;
|
||||
return [s, unescape(this.toString()), false, false];
|
||||
}
|
||||
// XXX abstract out this map method
|
||||
@@ -688,14 +541,11 @@ export class AST {
|
||||
let escaping = false;
|
||||
let re = '';
|
||||
let uflag = false;
|
||||
// multiple stars that aren't globstars coalesce into one *
|
||||
let inStar = false;
|
||||
for (let i = 0; i < glob.length; i++) {
|
||||
const c = glob.charAt(i);
|
||||
if (escaping) {
|
||||
escaping = false;
|
||||
re += (reSpecials.has(c) ? '\\' : '') + c;
|
||||
inStar = false;
|
||||
continue;
|
||||
}
|
||||
if (c === '\\') {
|
||||
@@ -714,21 +564,17 @@ export class AST {
|
||||
uflag = uflag || needUflag;
|
||||
i += consumed - 1;
|
||||
hasMagic = hasMagic || magic;
|
||||
inStar = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c === '*') {
|
||||
if (inStar)
|
||||
continue;
|
||||
inStar = true;
|
||||
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
||||
if (noEmpty && glob === '*')
|
||||
re += starNoEmpty;
|
||||
else
|
||||
re += star;
|
||||
hasMagic = true;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
inStar = false;
|
||||
}
|
||||
if (c === '?') {
|
||||
re += qmark;
|
||||
hasMagic = true;
|
||||
@@ -739,5 +585,4 @@ export class AST {
|
||||
return [re, unescape(glob), !!hasMagic, uflag];
|
||||
}
|
||||
}
|
||||
_a = AST;
|
||||
//# sourceMappingURL=ast.js.map
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"brace-expressions.d.ts","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;CAClB,CAAA;AAQD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,KACf,gBA6HF,CAAA"}
|
||||
{"version":3,"file":"brace-expressions.d.ts","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;CAClB,CAAA;AAQD,eAAO,MAAM,UAAU,SACf,MAAM,YACF,MAAM,qBA8HjB,CAAA"}
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -8,5 +8,5 @@ import { MinimatchOptions } from './index.js';
|
||||
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
||||
* not interpreted as a magic character, but instead as a path separator.
|
||||
*/
|
||||
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, "windowsPathsNoEscape">) => string;
|
||||
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>) => string;
|
||||
//# sourceMappingURL=escape.d.ts.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,GACjB,GAAG,MAAM,EACT,4BAEG,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,WAQvD,CAAA"}
|
||||
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MACd,MAAM,8BAGN,KAAK,gBAAgB,EAAE,sBAAsB,CAAC,WAQlD,CAAA"}
|
||||
Generated
Vendored
-4
@@ -21,8 +21,6 @@ export interface MinimatchOptions {
|
||||
optimizationLevel?: number;
|
||||
platform?: Platform;
|
||||
windowsNoMagicRoot?: boolean;
|
||||
maxGlobstarRecursion?: number;
|
||||
maxExtglobRecursion?: number;
|
||||
}
|
||||
export declare const minimatch: {
|
||||
(p: string, pattern: string, options?: MinimatchOptions): boolean;
|
||||
@@ -53,7 +51,6 @@ export type MMRegExp = RegExp & {
|
||||
export type ParseReturnFiltered = string | MMRegExp | typeof GLOBSTAR;
|
||||
export type ParseReturn = ParseReturnFiltered | false;
|
||||
export declare class Minimatch {
|
||||
#private;
|
||||
options: MinimatchOptions;
|
||||
set: ParseReturnFiltered[][];
|
||||
pattern: string;
|
||||
@@ -70,7 +67,6 @@ export declare class Minimatch {
|
||||
isWindows: boolean;
|
||||
platform: Platform;
|
||||
windowsNoMagicRoot: boolean;
|
||||
maxGlobstarRecursion: number;
|
||||
regexp: false | null | MMRegExp;
|
||||
constructor(pattern: string, options?: MinimatchOptions);
|
||||
hasMagic(): boolean;
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAe,MAAM,UAAU,CAAA;AAI3C,KAAK,QAAQ,GACT,KAAK,GACL,SAAS,GACT,QAAQ,GACR,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,GACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA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AAM,EAAE,EAAE;IAoBtC,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IA6D7C,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE;IA0F1C,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE;IAkBxD,UAAU,CACR,CAAC,EAAE,MAAM,EAAE,EACX,CAAC,EAAE,MAAM,EAAE,EACX,YAAY,GAAE,OAAe,GAC5B,KAAK,GAAG,MAAM,EAAE;IA+CnB,WAAW;IAqBX,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE,OAAe;IAiNzE,WAAW;IAIX,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAiDnC,MAAM;IAsFN,UAAU,CAAC,CAAC,EAAE,MAAM;IAepB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,UAAe;IAiEvC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB;CAGtC;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
|
||||
Generated
Vendored
+120
-126
@@ -193,13 +193,11 @@ export class Minimatch {
|
||||
isWindows;
|
||||
platform;
|
||||
windowsNoMagicRoot;
|
||||
maxGlobstarRecursion;
|
||||
regexp;
|
||||
constructor(pattern, options = {}) {
|
||||
assertValidPattern(pattern);
|
||||
options = options || {};
|
||||
this.options = options;
|
||||
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
||||
this.pattern = pattern;
|
||||
this.platform = options.platform || defaultPlatform;
|
||||
this.isWindows = this.platform === 'win32';
|
||||
@@ -599,8 +597,7 @@ export class Minimatch {
|
||||
// out of pattern, then that's fine, as long as all
|
||||
// the parts match.
|
||||
matchOne(file, pattern, partial = false) {
|
||||
let fileStartIndex = 0;
|
||||
let patternStartIndex = 0;
|
||||
const options = this.options;
|
||||
// UNC paths like //?/X:/... can match X:/... and vice versa
|
||||
// Drive letters in absolute drive or unc paths are always compared
|
||||
// case-insensitively.
|
||||
@@ -621,14 +618,15 @@ export class Minimatch {
|
||||
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
||||
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
||||
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
||||
const [fd, pd] = [
|
||||
file[fdi],
|
||||
pattern[pdi],
|
||||
];
|
||||
const [fd, pd] = [file[fdi], pattern[pdi]];
|
||||
if (fd.toLowerCase() === pd.toLowerCase()) {
|
||||
pattern[pdi] = fd;
|
||||
patternStartIndex = pdi;
|
||||
fileStartIndex = fdi;
|
||||
if (pdi > fdi) {
|
||||
pattern = pattern.slice(pdi);
|
||||
}
|
||||
else if (fdi > pdi) {
|
||||
file = file.slice(fdi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,127 +636,102 @@ export class Minimatch {
|
||||
if (optimizationLevel >= 2) {
|
||||
file = this.levelTwoFileOptimize(file);
|
||||
}
|
||||
if (pattern.includes(GLOBSTAR)) {
|
||||
return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
||||
}
|
||||
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
||||
}
|
||||
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
||||
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
||||
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
||||
const [head, body, tail] = partial ? [
|
||||
pattern.slice(patternIndex, firstgs),
|
||||
pattern.slice(firstgs + 1),
|
||||
[],
|
||||
] : [
|
||||
pattern.slice(patternIndex, firstgs),
|
||||
pattern.slice(firstgs + 1, lastgs),
|
||||
pattern.slice(lastgs + 1),
|
||||
];
|
||||
if (head.length) {
|
||||
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
||||
if (!this.#matchOne(fileHead, head, partial, 0, 0))
|
||||
return false;
|
||||
fileIndex += head.length;
|
||||
}
|
||||
let fileTailMatch = 0;
|
||||
if (tail.length) {
|
||||
if (tail.length + fileIndex > file.length)
|
||||
return false;
|
||||
let tailStart = file.length - tail.length;
|
||||
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
|
||||
fileTailMatch = tail.length;
|
||||
}
|
||||
else {
|
||||
if (file[file.length - 1] !== '' ||
|
||||
fileIndex + tail.length === file.length) {
|
||||
return false;
|
||||
}
|
||||
tailStart--;
|
||||
if (!this.#matchOne(file, tail, partial, tailStart, 0))
|
||||
return false;
|
||||
fileTailMatch = tail.length + 1;
|
||||
}
|
||||
}
|
||||
if (!body.length) {
|
||||
let sawSome = !!fileTailMatch;
|
||||
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
|
||||
const f = String(file[i]);
|
||||
sawSome = true;
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return partial || sawSome;
|
||||
}
|
||||
const bodySegments = [[[], 0]];
|
||||
let currentBody = bodySegments[0];
|
||||
let nonGsParts = 0;
|
||||
const nonGsPartsSums = [0];
|
||||
for (const b of body) {
|
||||
if (b === GLOBSTAR) {
|
||||
nonGsPartsSums.push(nonGsParts);
|
||||
currentBody = [[], 0];
|
||||
bodySegments.push(currentBody);
|
||||
}
|
||||
else {
|
||||
currentBody[0].push(b);
|
||||
nonGsParts++;
|
||||
}
|
||||
}
|
||||
let i = bodySegments.length - 1;
|
||||
const fileLength = file.length - fileTailMatch;
|
||||
for (const b of bodySegments) {
|
||||
b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
||||
}
|
||||
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
||||
}
|
||||
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
||||
const bs = bodySegments[bodyIndex];
|
||||
if (!bs) {
|
||||
for (let i = fileIndex; i < file.length; i++) {
|
||||
sawTail = true;
|
||||
const f = file[i];
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return sawTail;
|
||||
}
|
||||
const [body, after] = bs;
|
||||
while (fileIndex <= after) {
|
||||
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
||||
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
||||
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
||||
if (sub !== false)
|
||||
return sub;
|
||||
}
|
||||
const f = file[fileIndex];
|
||||
if (f === '.' || f === '..' ||
|
||||
(!this.options.dot && f.startsWith('.'))) {
|
||||
return false;
|
||||
}
|
||||
fileIndex++;
|
||||
}
|
||||
return partial || null;
|
||||
}
|
||||
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
||||
let fi;
|
||||
let pi;
|
||||
let pl;
|
||||
let fl;
|
||||
for (fi = fileIndex, pi = patternIndex,
|
||||
fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
||||
this.debug('matchOne', this, { file, pattern });
|
||||
this.debug('matchOne', file.length, pattern.length);
|
||||
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
||||
this.debug('matchOne loop');
|
||||
let p = pattern[pi];
|
||||
let f = file[fi];
|
||||
var p = pattern[pi];
|
||||
var f = file[fi];
|
||||
this.debug(pattern, p, f);
|
||||
// should be impossible.
|
||||
// some invalid regexp stuff in the set.
|
||||
/* c8 ignore start */
|
||||
if (p === false || p === GLOBSTAR)
|
||||
if (p === false) {
|
||||
return false;
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
if (p === GLOBSTAR) {
|
||||
this.debug('GLOBSTAR', [pattern, p, f]);
|
||||
// "**"
|
||||
// a/**/b/**/c would match the following:
|
||||
// a/b/x/y/z/c
|
||||
// a/x/y/z/b/c
|
||||
// a/b/x/b/x/c
|
||||
// a/b/c
|
||||
// To do this, take the rest of the pattern after
|
||||
// the **, and see if it would match the file remainder.
|
||||
// If so, return success.
|
||||
// If not, the ** "swallows" a segment, and try again.
|
||||
// This is recursively awful.
|
||||
//
|
||||
// a/**/b/**/c matching a/b/x/y/z/c
|
||||
// - a matches a
|
||||
// - doublestar
|
||||
// - matchOne(b/x/y/z/c, b/**/c)
|
||||
// - b matches b
|
||||
// - doublestar
|
||||
// - matchOne(x/y/z/c, c) -> no
|
||||
// - matchOne(y/z/c, c) -> no
|
||||
// - matchOne(z/c, c) -> no
|
||||
// - matchOne(c, c) yes, hit
|
||||
var fr = fi;
|
||||
var pr = pi + 1;
|
||||
if (pr === pl) {
|
||||
this.debug('** at the end');
|
||||
// a ** at the end will just swallow the rest.
|
||||
// We have found a match.
|
||||
// however, it will not swallow /.x, unless
|
||||
// options.dot is set.
|
||||
// . and .. are *never* matched by **, for explosively
|
||||
// exponential reasons.
|
||||
for (; fi < fl; fi++) {
|
||||
if (file[fi] === '.' ||
|
||||
file[fi] === '..' ||
|
||||
(!options.dot && file[fi].charAt(0) === '.'))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// ok, let's see if we can swallow whatever we can.
|
||||
while (fr < fl) {
|
||||
var swallowee = file[fr];
|
||||
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
||||
// XXX remove this slice. Just pass the start index.
|
||||
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
||||
this.debug('globstar found match!', fr, fl, swallowee);
|
||||
// found a match.
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// can't swallow "." or ".." ever.
|
||||
// can only swallow ".foo" when explicitly asked.
|
||||
if (swallowee === '.' ||
|
||||
swallowee === '..' ||
|
||||
(!options.dot && swallowee.charAt(0) === '.')) {
|
||||
this.debug('dot detected!', file, fr, pattern, pr);
|
||||
break;
|
||||
}
|
||||
// ** swallows a segment, and continue.
|
||||
this.debug('globstar swallow a segment, and continue');
|
||||
fr++;
|
||||
}
|
||||
}
|
||||
// no match was found.
|
||||
// However, in partial mode, we can't say this is necessarily over.
|
||||
/* c8 ignore start */
|
||||
if (partial) {
|
||||
// ran out of file
|
||||
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
||||
if (fr === fl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
return false;
|
||||
}
|
||||
// something other than **
|
||||
// non-magic patterns just have to match exactly
|
||||
// patterns with magic have been turned into regexps.
|
||||
let hit;
|
||||
if (typeof p === 'string') {
|
||||
hit = f === p;
|
||||
@@ -771,17 +744,38 @@ export class Minimatch {
|
||||
if (!hit)
|
||||
return false;
|
||||
}
|
||||
// Note: ending in / means that we'll get a final ""
|
||||
// at the end of the pattern. This can only match a
|
||||
// corresponding "" at the end of the file.
|
||||
// If the file ends in /, then it can only match a
|
||||
// a pattern that ends in /, unless the pattern just
|
||||
// doesn't have any more for it. But, a/b/ should *not*
|
||||
// match "a/b/*", even though "" matches against the
|
||||
// [^/]*? pattern, except in partial mode, where it might
|
||||
// simply not be reached yet.
|
||||
// However, a/b/ should still satisfy a/*
|
||||
// now either we fell off the end of the pattern, or we're done.
|
||||
if (fi === fl && pi === pl) {
|
||||
// ran out of pattern and filename at the same time.
|
||||
// an exact hit!
|
||||
return true;
|
||||
}
|
||||
else if (fi === fl) {
|
||||
// ran out of file, but still had pattern left.
|
||||
// this is ok if we're doing the match as part of
|
||||
// a glob fs traversal.
|
||||
return partial;
|
||||
}
|
||||
else if (pi === pl) {
|
||||
// ran out of pattern, still have file left.
|
||||
// this is only acceptable if we're on the very last
|
||||
// empty segment of a file with a trailing slash.
|
||||
// a/* should match a/b/
|
||||
return fi === fl - 1 && file[fi] === '';
|
||||
/* c8 ignore start */
|
||||
}
|
||||
else {
|
||||
// should be unreachable.
|
||||
throw new Error('wtf?');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
Generated
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
+1
-1
@@ -13,5 +13,5 @@ import { MinimatchOptions } from './index.js';
|
||||
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
||||
* or unescaped.
|
||||
*/
|
||||
export declare const unescape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, "windowsPathsNoEscape">) => string;
|
||||
export declare const unescape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>) => string;
|
||||
//# sourceMappingURL=unescape.d.ts.map
|
||||
Generated
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,EACT,4BAEG,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAM,WAKvD,CAAA"}
|
||||
{"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../src/unescape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,MAChB,MAAM,8BAGN,KAAK,gBAAgB,EAAE,sBAAsB,CAAC,WAKlD,CAAA"}
|
||||
Generated
Vendored
+14
-14
@@ -2,7 +2,7 @@
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
|
||||
"name": "minimatch",
|
||||
"description": "a glob matcher in javascript",
|
||||
"version": "9.0.9",
|
||||
"version": "9.0.5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/minimatch.git"
|
||||
@@ -53,16 +53,20 @@
|
||||
"node": ">=16 || 14 >=14.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.2"
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/brace-expansion": "^1.1.2",
|
||||
"@types/node": "^25.3.0",
|
||||
"mkdirp": "^3.0.1",
|
||||
"prettier": "^3.8.1",
|
||||
"tap": "^21.6.1",
|
||||
"tshy": "^3.3.2",
|
||||
"typescript": "^5.5.3"
|
||||
"@types/brace-expansion": "^1.1.0",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/tap": "^15.0.8",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"mkdirp": "1",
|
||||
"prettier": "^2.8.2",
|
||||
"tap": "^18.7.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"tshy": "^1.12.0",
|
||||
"typedoc": "^0.23.21",
|
||||
"typescript": "^4.9.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
@@ -74,9 +78,5 @@
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"tag": "legacy-v9"
|
||||
},
|
||||
"module": "./dist/esm/index.js"
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user