@@ -107350,10 +107350,10 @@ module.exports = mime;
107350
107350
module.exports = minimatch
107351
107351
minimatch.Minimatch = Minimatch
107352
107352
107353
- var path = { sep: '/' }
107354
- try {
107355
- path = __nccwpck_require__(71017)
107356
- } catch (er) {}
107353
+ var path = (function () { try { return __nccwpck_require__(71017) } catch (e) {}}()) || {
107354
+ sep: '/'
107355
+ }
107356
+ minimatch.sep = path.sep
107357
107357
107358
107358
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
107359
107359
var expand = __nccwpck_require__(33717)
@@ -107405,43 +107405,64 @@ function filter (pattern, options) {
107405
107405
}
107406
107406
107407
107407
function ext (a, b) {
107408
- a = a || {}
107409
107408
b = b || {}
107410
107409
var t = {}
107411
- Object.keys(b).forEach(function (k) {
107412
- t[k] = b[k]
107413
- })
107414
107410
Object.keys(a).forEach(function (k) {
107415
107411
t[k] = a[k]
107416
107412
})
107413
+ Object.keys(b).forEach(function (k) {
107414
+ t[k] = b[k]
107415
+ })
107417
107416
return t
107418
107417
}
107419
107418
107420
107419
minimatch.defaults = function (def) {
107421
- if (!def || !Object.keys(def).length) return minimatch
107420
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
107421
+ return minimatch
107422
+ }
107422
107423
107423
107424
var orig = minimatch
107424
107425
107425
107426
var m = function minimatch (p, pattern, options) {
107426
- return orig.minimatch (p, pattern, ext(def, options))
107427
+ return orig(p, pattern, ext(def, options))
107427
107428
}
107428
107429
107429
107430
m.Minimatch = function Minimatch (pattern, options) {
107430
107431
return new orig.Minimatch(pattern, ext(def, options))
107431
107432
}
107433
+ m.Minimatch.defaults = function defaults (options) {
107434
+ return orig.defaults(ext(def, options)).Minimatch
107435
+ }
107436
+
107437
+ m.filter = function filter (pattern, options) {
107438
+ return orig.filter(pattern, ext(def, options))
107439
+ }
107440
+
107441
+ m.defaults = function defaults (options) {
107442
+ return orig.defaults(ext(def, options))
107443
+ }
107444
+
107445
+ m.makeRe = function makeRe (pattern, options) {
107446
+ return orig.makeRe(pattern, ext(def, options))
107447
+ }
107448
+
107449
+ m.braceExpand = function braceExpand (pattern, options) {
107450
+ return orig.braceExpand(pattern, ext(def, options))
107451
+ }
107452
+
107453
+ m.match = function (list, pattern, options) {
107454
+ return orig.match(list, pattern, ext(def, options))
107455
+ }
107432
107456
107433
107457
return m
107434
107458
}
107435
107459
107436
107460
Minimatch.defaults = function (def) {
107437
- if (!def || !Object.keys(def).length) return Minimatch
107438
107461
return minimatch.defaults(def).Minimatch
107439
107462
}
107440
107463
107441
107464
function minimatch (p, pattern, options) {
107442
- if (typeof pattern !== 'string') {
107443
- throw new TypeError('glob pattern string required')
107444
- }
107465
+ assertValidPattern(pattern)
107445
107466
107446
107467
if (!options) options = {}
107447
107468
@@ -107450,9 +107471,6 @@ function minimatch (p, pattern, options) {
107450
107471
return false
107451
107472
}
107452
107473
107453
- // "" only matches ""
107454
- if (pattern.trim() === '') return p === ''
107455
-
107456
107474
return new Minimatch(pattern, options).match(p)
107457
107475
}
107458
107476
@@ -107461,15 +107479,14 @@ function Minimatch (pattern, options) {
107461
107479
return new Minimatch(pattern, options)
107462
107480
}
107463
107481
107464
- if (typeof pattern !== 'string') {
107465
- throw new TypeError('glob pattern string required')
107466
- }
107482
+ assertValidPattern(pattern)
107467
107483
107468
107484
if (!options) options = {}
107485
+
107469
107486
pattern = pattern.trim()
107470
107487
107471
107488
// windows support: need to use /, not \
107472
- if (path.sep !== '/') {
107489
+ if (!options.allowWindowsEscape && path.sep !== '/') {
107473
107490
pattern = pattern.split(path.sep).join('/')
107474
107491
}
107475
107492
@@ -107480,6 +107497,7 @@ function Minimatch (pattern, options) {
107480
107497
this.negate = false
107481
107498
this.comment = false
107482
107499
this.empty = false
107500
+ this.partial = !!options.partial
107483
107501
107484
107502
// make the set of regexps etc.
107485
107503
this.make()
@@ -107489,9 +107507,6 @@ Minimatch.prototype.debug = function () {}
107489
107507
107490
107508
Minimatch.prototype.make = make
107491
107509
function make () {
107492
- // don't do it more than once.
107493
- if (this._made) return
107494
-
107495
107510
var pattern = this.pattern
107496
107511
var options = this.options
107497
107512
@@ -107511,7 +107526,7 @@ function make () {
107511
107526
// step 2: expand braces
107512
107527
var set = this.globSet = this.braceExpand()
107513
107528
107514
- if (options.debug) this.debug = console.error
107529
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
107515
107530
107516
107531
this.debug(this.pattern, set)
107517
107532
@@ -107591,19 +107606,29 @@ function braceExpand (pattern, options) {
107591
107606
pattern = typeof pattern === 'undefined'
107592
107607
? this.pattern : pattern
107593
107608
107594
- if (typeof pattern === 'undefined') {
107595
- throw new TypeError('undefined pattern')
107596
- }
107609
+ assertValidPattern(pattern)
107597
107610
107598
- if (options.nobrace ||
107599
- !pattern.match(/\{.*\}/)) {
107611
+ // Thanks to Yeting Li <https://github.com/yetingli> for
107612
+ // improving this regexp to avoid a ReDOS vulnerability.
107613
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
107600
107614
// shortcut. no need to expand.
107601
107615
return [pattern]
107602
107616
}
107603
107617
107604
107618
return expand(pattern)
107605
107619
}
107606
107620
107621
+ var MAX_PATTERN_LENGTH = 1024 * 64
107622
+ var assertValidPattern = function (pattern) {
107623
+ if (typeof pattern !== 'string') {
107624
+ throw new TypeError('invalid pattern')
107625
+ }
107626
+
107627
+ if (pattern.length > MAX_PATTERN_LENGTH) {
107628
+ throw new TypeError('pattern is too long')
107629
+ }
107630
+ }
107631
+
107607
107632
// parse a component of the expanded set.
107608
107633
// At this point, no pattern may contain "/" in it
107609
107634
// so we're going to return a 2d array, where each entry is the full
@@ -107618,14 +107643,17 @@ function braceExpand (pattern, options) {
107618
107643
Minimatch.prototype.parse = parse
107619
107644
var SUBPARSE = {}
107620
107645
function parse (pattern, isSub) {
107621
- if (pattern.length > 1024 * 64) {
107622
- throw new TypeError('pattern is too long')
107623
- }
107646
+ assertValidPattern(pattern)
107624
107647
107625
107648
var options = this.options
107626
107649
107627
107650
// shortcuts
107628
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
107651
+ if (pattern === '**') {
107652
+ if (!options.noglobstar)
107653
+ return GLOBSTAR
107654
+ else
107655
+ pattern = '*'
107656
+ }
107629
107657
if (pattern === '') return ''
107630
107658
107631
107659
var re = ''
@@ -107681,10 +107709,12 @@ function parse (pattern, isSub) {
107681
107709
}
107682
107710
107683
107711
switch (c) {
107684
- case '/':
107712
+ /* istanbul ignore next */
107713
+ case '/': {
107685
107714
// completely not allowed, even escaped.
107686
107715
// Should already be path-split by now.
107687
107716
return false
107717
+ }
107688
107718
107689
107719
case '\\':
107690
107720
clearStateChar()
@@ -107803,25 +107833,23 @@ function parse (pattern, isSub) {
107803
107833
107804
107834
// handle the case where we left a class open.
107805
107835
// "[z-a]" is valid, equivalent to "\[z-a\]"
107806
- if (inClass) {
107807
- // split where the last [ was, make sure we don't have
107808
- // an invalid re. if so, re-walk the contents of the
107809
- // would-be class to re-translate any characters that
107810
- // were passed through as-is
107811
- // TODO: It would probably be faster to determine this
107812
- // without a try/catch and a new RegExp, but it's tricky
107813
- // to do safely. For now, this is safe and works.
107814
- var cs = pattern.substring(classStart + 1, i)
107815
- try {
107816
- RegExp('[' + cs + ']')
107817
- } catch (er) {
107818
- // not a valid class!
107819
- var sp = this.parse(cs, SUBPARSE)
107820
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
107821
- hasMagic = hasMagic || sp[1]
107822
- inClass = false
107823
- continue
107824
- }
107836
+ // split where the last [ was, make sure we don't have
107837
+ // an invalid re. if so, re-walk the contents of the
107838
+ // would-be class to re-translate any characters that
107839
+ // were passed through as-is
107840
+ // TODO: It would probably be faster to determine this
107841
+ // without a try/catch and a new RegExp, but it's tricky
107842
+ // to do safely. For now, this is safe and works.
107843
+ var cs = pattern.substring(classStart + 1, i)
107844
+ try {
107845
+ RegExp('[' + cs + ']')
107846
+ } catch (er) {
107847
+ // not a valid class!
107848
+ var sp = this.parse(cs, SUBPARSE)
107849
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
107850
+ hasMagic = hasMagic || sp[1]
107851
+ inClass = false
107852
+ continue
107825
107853
}
107826
107854
107827
107855
// finish up the class.
@@ -107905,9 +107933,7 @@ function parse (pattern, isSub) {
107905
107933
// something that could conceivably capture a dot
107906
107934
var addPatternStart = false
107907
107935
switch (re.charAt(0)) {
107908
- case '.':
107909
- case '[':
107910
- case '(': addPatternStart = true
107936
+ case '[': case '.': case '(': addPatternStart = true
107911
107937
}
107912
107938
107913
107939
// Hack to work around lack of negative lookbehind in JS
@@ -107969,7 +107995,7 @@ function parse (pattern, isSub) {
107969
107995
var flags = options.nocase ? 'i' : ''
107970
107996
try {
107971
107997
var regExp = new RegExp('^' + re + '$', flags)
107972
- } catch (er) {
107998
+ } catch (er) /* istanbul ignore next - should be impossible */ {
107973
107999
// If it was an invalid regular expression, then it can't match
107974
108000
// anything. This trick looks for a character after the end of
107975
108001
// the string, which is of course impossible, except in multi-line
@@ -108027,7 +108053,7 @@ function makeRe () {
108027
108053
108028
108054
try {
108029
108055
this.regexp = new RegExp(re, flags)
108030
- } catch (ex) {
108056
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
108031
108057
this.regexp = false
108032
108058
}
108033
108059
return this.regexp
@@ -108045,8 +108071,8 @@ minimatch.match = function (list, pattern, options) {
108045
108071
return list
108046
108072
}
108047
108073
108048
- Minimatch.prototype.match = match
108049
- function match (f, partial) {
108074
+ Minimatch.prototype.match = function match (f, partial) {
108075
+ if (typeof partial === 'undefined') partial = this.partial
108050
108076
this.debug('match', f, this.pattern)
108051
108077
// short-circuit in the case of busted things.
108052
108078
// comments, etc.
@@ -108128,6 +108154,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108128
108154
108129
108155
// should be impossible.
108130
108156
// some invalid regexp stuff in the set.
108157
+ /* istanbul ignore if */
108131
108158
if (p === false) return false
108132
108159
108133
108160
if (p === GLOBSTAR) {
@@ -108201,6 +108228,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108201
108228
// no match was found.
108202
108229
// However, in partial mode, we can't say this is necessarily over.
108203
108230
// If there's more *pattern* left, then
108231
+ /* istanbul ignore if */
108204
108232
if (partial) {
108205
108233
// ran out of file
108206
108234
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -108214,11 +108242,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108214
108242
// patterns with magic have been turned into regexps.
108215
108243
var hit
108216
108244
if (typeof p === 'string') {
108217
- if (options.nocase) {
108218
- hit = f.toLowerCase() === p.toLowerCase()
108219
- } else {
108220
- hit = f === p
108221
- }
108245
+ hit = f === p
108222
108246
this.debug('string match', p, f, hit)
108223
108247
} else {
108224
108248
hit = f.match(p)
@@ -108249,16 +108273,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108249
108273
// this is ok if we're doing the match as part of
108250
108274
// a glob fs traversal.
108251
108275
return partial
108252
- } else if (pi === pl) {
108276
+ } else /* istanbul ignore else */ if (pi === pl) {
108253
108277
// ran out of pattern, still have file left.
108254
108278
// this is only acceptable if we're on the very last
108255
108279
// empty segment of a file with a trailing slash.
108256
108280
// a/* should match a/b/
108257
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
108258
- return emptyFileEnd
108281
+ return (fi === fl - 1) && (file[fi] === '')
108259
108282
}
108260
108283
108261
108284
// should be unreachable.
108285
+ /* istanbul ignore next */
108262
108286
throw new Error('wtf?')
108263
108287
}
108264
108288
0 commit comments