@pnpm/exe 11.9.0 → 11.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
File without changes
@@ -230,7 +230,15 @@ const parseRepeatedExtglob = (pattern, requireEnd = true) => {
230
230
  }
231
231
  };
232
232
 
233
- const getStarExtglobSequenceOutput = pattern => {
233
+ const buildCharClassStar = chars => {
234
+ const source = chars.length === 1
235
+ ? utils.escapeRegex(chars[0])
236
+ : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
237
+
238
+ return `${source}*`;
239
+ };
240
+
241
+ const getStarExtglobSequenceChars = pattern => {
234
242
  let index = 0;
235
243
  const chars = [];
236
244
 
@@ -259,11 +267,7 @@ const getStarExtglobSequenceOutput = pattern => {
259
267
  return;
260
268
  }
261
269
 
262
- const source = chars.length === 1
263
- ? utils.escapeRegex(chars[0])
264
- : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
265
-
266
- return `${source}*`;
270
+ return chars;
267
271
  };
268
272
 
269
273
  const repeatedExtglobRecursion = pattern => {
@@ -302,17 +306,43 @@ const analyzeRepeatedExtglob = (body, options) => {
302
306
  }
303
307
  }
304
308
 
309
+ // A repeated extglob is "risky" (prone to catastrophic backtracking) when a
310
+ // branch is itself a `*(...)` sequence, since that nests an unbounded quantifier
311
+ // inside the outer `+(...)`/`*(...)`. When *every* branch reduces to single
312
+ // characters we can emit one flat, ReDoS-safe character class that preserves the
313
+ // meaning of ALL branches (e.g. `+(*(a)|*(b))` -> `[ab]*`), rather than dropping
314
+ // every branch but the first.
315
+ const safeChars = [];
316
+ let sawStarSequence = false;
317
+ let combinable = true;
318
+
305
319
  for (const branch of branches) {
306
- const safeOutput = getStarExtglobSequenceOutput(branch);
307
- if (safeOutput) {
308
- return { risky: true, safeOutput };
320
+ const chars = getStarExtglobSequenceChars(branch);
321
+ if (chars) {
322
+ sawStarSequence = true;
323
+ safeChars.push(...chars);
324
+ continue;
325
+ }
326
+
327
+ const literal = normalizeSimpleBranch(branch);
328
+ if (literal && literal.length === 1) {
329
+ safeChars.push(literal);
330
+ continue;
309
331
  }
310
332
 
333
+ combinable = false;
334
+
311
335
  if (repeatedExtglobRecursion(branch) > max) {
312
336
  return { risky: true };
313
337
  }
314
338
  }
315
339
 
340
+ if (sawStarSequence) {
341
+ return combinable
342
+ ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) }
343
+ : { risky: true };
344
+ }
345
+
316
346
  return { risky: false };
317
347
  };
318
348
 
@@ -20,6 +20,18 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
20
20
  * const isMatch = picomatch('*.!(*a)');
21
21
  * console.log(isMatch('a.a')); //=> false
22
22
  * console.log(isMatch('a.b')); //=> true
23
+ *
24
+ * // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
25
+ * const picomatch = require('picomatch/posix');
26
+ * // the same API, defaulting to posix paths
27
+ * const isMatch = picomatch('a/*');
28
+ * console.log(isMatch('a\\b')); //=> false
29
+ * console.log(isMatch('a/b')); //=> true
30
+ *
31
+ * // you can still configure the matcher function to accept windows paths
32
+ * const isMatch = picomatch('a/*', { options: windows });
33
+ * console.log(isMatch('a\\b')); //=> true
34
+ * console.log(isMatch('a/b')); //=> true
23
35
  * ```
24
36
  * @name picomatch
25
37
  * @param {String|Array} `globs` One or more glob patterns.
@@ -157,9 +169,9 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
157
169
  * @api public
158
170
  */
159
171
 
160
- picomatch.matchBase = (input, glob, options) => {
172
+ picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
161
173
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
162
- return regex.test(utils.basename(input));
174
+ return regex.test(utils.basename(input, { windows: posix }));
163
175
  };
164
176
 
165
177
  /**
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "picomatch",
3
3
  "description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
4
- "version": "4.0.4",
4
+ "version": "4.0.5",
5
5
  "homepage": "https://github.com/micromatch/picomatch",
6
6
  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
7
  "funding": "https://github.com/sponsors/jonschlinkert",
@@ -43,7 +43,8 @@
43
43
  "reporter": [
44
44
  "html",
45
45
  "lcov",
46
- "text-summary"
46
+ "text-summary",
47
+ "cobertura"
47
48
  ]
48
49
  },
49
50
  "verb": {
@@ -41,6 +41,7 @@ exports.Header = void 0;
41
41
  const node_path_1 = require("node:path");
42
42
  const large = __importStar(require("./large-numbers.js"));
43
43
  const types = __importStar(require("./types.js"));
44
+ const notNegative = (n) => n === undefined || n < 0 ? undefined : n;
44
45
  class Header {
45
46
  cksumValid = false;
46
47
  needPax = false;
@@ -99,10 +100,9 @@ class Header {
99
100
  exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8);
100
101
  this.gid =
101
102
  exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8);
102
- this.size =
103
- exForFields?.size ??
104
- gexForFields?.size ??
105
- decNumber(buf, off + 124, 12);
103
+ this.size = notNegative(exForFields?.size ??
104
+ gexForFields?.size ??
105
+ decNumber(buf, off + 124, 12));
106
106
  this.mtime =
107
107
  exForFields?.mtime ??
108
108
  gexForFields?.mtime ??
@@ -188,6 +188,7 @@ class Header {
188
188
  // null/undefined values are ignored.
189
189
  return !(v === null ||
190
190
  v === undefined ||
191
+ (k === 'size' && Number(v) < 0) ||
191
192
  (k === 'path' && gex) ||
192
193
  (k === 'linkpath' && gex) ||
193
194
  k === 'global');