@@ -53331,10 +53331,10 @@ function populateMaps (extensions, types) {
53331
53331
module.exports = minimatch
53332
53332
minimatch.Minimatch = Minimatch
53333
53333
53334
- var path = { sep: '/' }
53335
- try {
53336
- path = __nccwpck_require__(1017)
53337
- } catch (er) {}
53334
+ var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || {
53335
+ sep: '/'
53336
+ }
53337
+ minimatch.sep = path.sep
53338
53338
53339
53339
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
53340
53340
var expand = __nccwpck_require__(3717)
@@ -53386,43 +53386,64 @@ function filter (pattern, options) {
53386
53386
}
53387
53387
53388
53388
function ext (a, b) {
53389
- a = a || {}
53390
53389
b = b || {}
53391
53390
var t = {}
53392
- Object.keys(b).forEach(function (k) {
53393
- t[k] = b[k]
53394
- })
53395
53391
Object.keys(a).forEach(function (k) {
53396
53392
t[k] = a[k]
53397
53393
})
53394
+ Object.keys(b).forEach(function (k) {
53395
+ t[k] = b[k]
53396
+ })
53398
53397
return t
53399
53398
}
53400
53399
53401
53400
minimatch.defaults = function (def) {
53402
- if (!def || !Object.keys(def).length) return minimatch
53401
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
53402
+ return minimatch
53403
+ }
53403
53404
53404
53405
var orig = minimatch
53405
53406
53406
53407
var m = function minimatch (p, pattern, options) {
53407
- return orig.minimatch (p, pattern, ext(def, options))
53408
+ return orig(p, pattern, ext(def, options))
53408
53409
}
53409
53410
53410
53411
m.Minimatch = function Minimatch (pattern, options) {
53411
53412
return new orig.Minimatch(pattern, ext(def, options))
53412
53413
}
53414
+ m.Minimatch.defaults = function defaults (options) {
53415
+ return orig.defaults(ext(def, options)).Minimatch
53416
+ }
53417
+
53418
+ m.filter = function filter (pattern, options) {
53419
+ return orig.filter(pattern, ext(def, options))
53420
+ }
53421
+
53422
+ m.defaults = function defaults (options) {
53423
+ return orig.defaults(ext(def, options))
53424
+ }
53425
+
53426
+ m.makeRe = function makeRe (pattern, options) {
53427
+ return orig.makeRe(pattern, ext(def, options))
53428
+ }
53429
+
53430
+ m.braceExpand = function braceExpand (pattern, options) {
53431
+ return orig.braceExpand(pattern, ext(def, options))
53432
+ }
53433
+
53434
+ m.match = function (list, pattern, options) {
53435
+ return orig.match(list, pattern, ext(def, options))
53436
+ }
53413
53437
53414
53438
return m
53415
53439
}
53416
53440
53417
53441
Minimatch.defaults = function (def) {
53418
- if (!def || !Object.keys(def).length) return Minimatch
53419
53442
return minimatch.defaults(def).Minimatch
53420
53443
}
53421
53444
53422
53445
function minimatch (p, pattern, options) {
53423
- if (typeof pattern !== 'string') {
53424
- throw new TypeError('glob pattern string required')
53425
- }
53446
+ assertValidPattern(pattern)
53426
53447
53427
53448
if (!options) options = {}
53428
53449
@@ -53431,9 +53452,6 @@ function minimatch (p, pattern, options) {
53431
53452
return false
53432
53453
}
53433
53454
53434
- // "" only matches ""
53435
- if (pattern.trim() === '') return p === ''
53436
-
53437
53455
return new Minimatch(pattern, options).match(p)
53438
53456
}
53439
53457
@@ -53442,15 +53460,14 @@ function Minimatch (pattern, options) {
53442
53460
return new Minimatch(pattern, options)
53443
53461
}
53444
53462
53445
- if (typeof pattern !== 'string') {
53446
- throw new TypeError('glob pattern string required')
53447
- }
53463
+ assertValidPattern(pattern)
53448
53464
53449
53465
if (!options) options = {}
53466
+
53450
53467
pattern = pattern.trim()
53451
53468
53452
53469
// windows support: need to use /, not \
53453
- if (path.sep !== '/') {
53470
+ if (!options.allowWindowsEscape && path.sep !== '/') {
53454
53471
pattern = pattern.split(path.sep).join('/')
53455
53472
}
53456
53473
@@ -53461,6 +53478,7 @@ function Minimatch (pattern, options) {
53461
53478
this.negate = false
53462
53479
this.comment = false
53463
53480
this.empty = false
53481
+ this.partial = !!options.partial
53464
53482
53465
53483
// make the set of regexps etc.
53466
53484
this.make()
@@ -53470,9 +53488,6 @@ Minimatch.prototype.debug = function () {}
53470
53488
53471
53489
Minimatch.prototype.make = make
53472
53490
function make () {
53473
- // don't do it more than once.
53474
- if (this._made) return
53475
-
53476
53491
var pattern = this.pattern
53477
53492
var options = this.options
53478
53493
@@ -53492,7 +53507,7 @@ function make () {
53492
53507
// step 2: expand braces
53493
53508
var set = this.globSet = this.braceExpand()
53494
53509
53495
- if (options.debug) this.debug = console.error
53510
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
53496
53511
53497
53512
this.debug(this.pattern, set)
53498
53513
@@ -53572,19 +53587,29 @@ function braceExpand (pattern, options) {
53572
53587
pattern = typeof pattern === 'undefined'
53573
53588
? this.pattern : pattern
53574
53589
53575
- if (typeof pattern === 'undefined') {
53576
- throw new TypeError('undefined pattern')
53577
- }
53590
+ assertValidPattern(pattern)
53578
53591
53579
- if (options.nobrace ||
53580
- !pattern.match(/\{.*\}/)) {
53592
+ // Thanks to Yeting Li <https://github.com/yetingli> for
53593
+ // improving this regexp to avoid a ReDOS vulnerability.
53594
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
53581
53595
// shortcut. no need to expand.
53582
53596
return [pattern]
53583
53597
}
53584
53598
53585
53599
return expand(pattern)
53586
53600
}
53587
53601
53602
+ var MAX_PATTERN_LENGTH = 1024 * 64
53603
+ var assertValidPattern = function (pattern) {
53604
+ if (typeof pattern !== 'string') {
53605
+ throw new TypeError('invalid pattern')
53606
+ }
53607
+
53608
+ if (pattern.length > MAX_PATTERN_LENGTH) {
53609
+ throw new TypeError('pattern is too long')
53610
+ }
53611
+ }
53612
+
53588
53613
// parse a component of the expanded set.
53589
53614
// At this point, no pattern may contain "/" in it
53590
53615
// so we're going to return a 2d array, where each entry is the full
@@ -53599,14 +53624,17 @@ function braceExpand (pattern, options) {
53599
53624
Minimatch.prototype.parse = parse
53600
53625
var SUBPARSE = {}
53601
53626
function parse (pattern, isSub) {
53602
- if (pattern.length > 1024 * 64) {
53603
- throw new TypeError('pattern is too long')
53604
- }
53627
+ assertValidPattern(pattern)
53605
53628
53606
53629
var options = this.options
53607
53630
53608
53631
// shortcuts
53609
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
53632
+ if (pattern === '**') {
53633
+ if (!options.noglobstar)
53634
+ return GLOBSTAR
53635
+ else
53636
+ pattern = '*'
53637
+ }
53610
53638
if (pattern === '') return ''
53611
53639
53612
53640
var re = ''
@@ -53662,10 +53690,12 @@ function parse (pattern, isSub) {
53662
53690
}
53663
53691
53664
53692
switch (c) {
53665
- case '/':
53693
+ /* istanbul ignore next */
53694
+ case '/': {
53666
53695
// completely not allowed, even escaped.
53667
53696
// Should already be path-split by now.
53668
53697
return false
53698
+ }
53669
53699
53670
53700
case '\\':
53671
53701
clearStateChar()
@@ -53784,25 +53814,23 @@ function parse (pattern, isSub) {
53784
53814
53785
53815
// handle the case where we left a class open.
53786
53816
// "[z-a]" is valid, equivalent to "\[z-a\]"
53787
- if (inClass) {
53788
- // split where the last [ was, make sure we don't have
53789
- // an invalid re. if so, re-walk the contents of the
53790
- // would-be class to re-translate any characters that
53791
- // were passed through as-is
53792
- // TODO: It would probably be faster to determine this
53793
- // without a try/catch and a new RegExp, but it's tricky
53794
- // to do safely. For now, this is safe and works.
53795
- var cs = pattern.substring(classStart + 1, i)
53796
- try {
53797
- RegExp('[' + cs + ']')
53798
- } catch (er) {
53799
- // not a valid class!
53800
- var sp = this.parse(cs, SUBPARSE)
53801
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
53802
- hasMagic = hasMagic || sp[1]
53803
- inClass = false
53804
- continue
53805
- }
53817
+ // split where the last [ was, make sure we don't have
53818
+ // an invalid re. if so, re-walk the contents of the
53819
+ // would-be class to re-translate any characters that
53820
+ // were passed through as-is
53821
+ // TODO: It would probably be faster to determine this
53822
+ // without a try/catch and a new RegExp, but it's tricky
53823
+ // to do safely. For now, this is safe and works.
53824
+ var cs = pattern.substring(classStart + 1, i)
53825
+ try {
53826
+ RegExp('[' + cs + ']')
53827
+ } catch (er) {
53828
+ // not a valid class!
53829
+ var sp = this.parse(cs, SUBPARSE)
53830
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
53831
+ hasMagic = hasMagic || sp[1]
53832
+ inClass = false
53833
+ continue
53806
53834
}
53807
53835
53808
53836
// finish up the class.
@@ -53886,9 +53914,7 @@ function parse (pattern, isSub) {
53886
53914
// something that could conceivably capture a dot
53887
53915
var addPatternStart = false
53888
53916
switch (re.charAt(0)) {
53889
- case '.':
53890
- case '[':
53891
- case '(': addPatternStart = true
53917
+ case '[': case '.': case '(': addPatternStart = true
53892
53918
}
53893
53919
53894
53920
// Hack to work around lack of negative lookbehind in JS
@@ -53950,7 +53976,7 @@ function parse (pattern, isSub) {
53950
53976
var flags = options.nocase ? 'i' : ''
53951
53977
try {
53952
53978
var regExp = new RegExp('^' + re + '$', flags)
53953
- } catch (er) {
53979
+ } catch (er) /* istanbul ignore next - should be impossible */ {
53954
53980
// If it was an invalid regular expression, then it can't match
53955
53981
// anything. This trick looks for a character after the end of
53956
53982
// the string, which is of course impossible, except in multi-line
@@ -54008,7 +54034,7 @@ function makeRe () {
54008
54034
54009
54035
try {
54010
54036
this.regexp = new RegExp(re, flags)
54011
- } catch (ex) {
54037
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
54012
54038
this.regexp = false
54013
54039
}
54014
54040
return this.regexp
@@ -54026,8 +54052,8 @@ minimatch.match = function (list, pattern, options) {
54026
54052
return list
54027
54053
}
54028
54054
54029
- Minimatch.prototype.match = match
54030
- function match (f, partial) {
54055
+ Minimatch.prototype.match = function match (f, partial) {
54056
+ if (typeof partial === 'undefined') partial = this.partial
54031
54057
this.debug('match', f, this.pattern)
54032
54058
// short-circuit in the case of busted things.
54033
54059
// comments, etc.
@@ -54109,6 +54135,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
54109
54135
54110
54136
// should be impossible.
54111
54137
// some invalid regexp stuff in the set.
54138
+ /* istanbul ignore if */
54112
54139
if (p === false) return false
54113
54140
54114
54141
if (p === GLOBSTAR) {
@@ -54182,6 +54209,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
54182
54209
// no match was found.
54183
54210
// However, in partial mode, we can't say this is necessarily over.
54184
54211
// If there's more *pattern* left, then
54212
+ /* istanbul ignore if */
54185
54213
if (partial) {
54186
54214
// ran out of file
54187
54215
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -54195,11 +54223,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
54195
54223
// patterns with magic have been turned into regexps.
54196
54224
var hit
54197
54225
if (typeof p === 'string') {
54198
- if (options.nocase) {
54199
- hit = f.toLowerCase() === p.toLowerCase()
54200
- } else {
54201
- hit = f === p
54202
- }
54226
+ hit = f === p
54203
54227
this.debug('string match', p, f, hit)
54204
54228
} else {
54205
54229
hit = f.match(p)
@@ -54230,16 +54254,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
54230
54254
// this is ok if we're doing the match as part of
54231
54255
// a glob fs traversal.
54232
54256
return partial
54233
- } else if (pi === pl) {
54257
+ } else /* istanbul ignore else */ if (pi === pl) {
54234
54258
// ran out of pattern, still have file left.
54235
54259
// this is only acceptable if we're on the very last
54236
54260
// empty segment of a file with a trailing slash.
54237
54261
// a/* should match a/b/
54238
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
54239
- return emptyFileEnd
54262
+ return (fi === fl - 1) && (file[fi] === '')
54240
54263
}
54241
54264
54242
54265
// should be unreachable.
54266
+ /* istanbul ignore next */
54243
54267
throw new Error('wtf?')
54244
54268
}
54245
54269
0 commit comments