@@ -45312,10 +45312,10 @@ function populateMaps (extensions, types) {
45312
45312
module.exports = minimatch
45313
45313
minimatch.Minimatch = Minimatch
45314
45314
45315
- var path = { sep: '/' }
45316
- try {
45317
- path = __nccwpck_require__(1017)
45318
- } catch (er) {}
45315
+ var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || {
45316
+ sep: '/'
45317
+ }
45318
+ minimatch.sep = path.sep
45319
45319
45320
45320
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
45321
45321
var expand = __nccwpck_require__(3717)
@@ -45367,43 +45367,64 @@ function filter (pattern, options) {
45367
45367
}
45368
45368
45369
45369
function ext (a, b) {
45370
- a = a || {}
45371
45370
b = b || {}
45372
45371
var t = {}
45373
- Object.keys(b).forEach(function (k) {
45374
- t[k] = b[k]
45375
- })
45376
45372
Object.keys(a).forEach(function (k) {
45377
45373
t[k] = a[k]
45378
45374
})
45375
+ Object.keys(b).forEach(function (k) {
45376
+ t[k] = b[k]
45377
+ })
45379
45378
return t
45380
45379
}
45381
45380
45382
45381
minimatch.defaults = function (def) {
45383
- if (!def || !Object.keys(def).length) return minimatch
45382
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
45383
+ return minimatch
45384
+ }
45384
45385
45385
45386
var orig = minimatch
45386
45387
45387
45388
var m = function minimatch (p, pattern, options) {
45388
- return orig.minimatch (p, pattern, ext(def, options))
45389
+ return orig(p, pattern, ext(def, options))
45389
45390
}
45390
45391
45391
45392
m.Minimatch = function Minimatch (pattern, options) {
45392
45393
return new orig.Minimatch(pattern, ext(def, options))
45393
45394
}
45395
+ m.Minimatch.defaults = function defaults (options) {
45396
+ return orig.defaults(ext(def, options)).Minimatch
45397
+ }
45398
+
45399
+ m.filter = function filter (pattern, options) {
45400
+ return orig.filter(pattern, ext(def, options))
45401
+ }
45402
+
45403
+ m.defaults = function defaults (options) {
45404
+ return orig.defaults(ext(def, options))
45405
+ }
45406
+
45407
+ m.makeRe = function makeRe (pattern, options) {
45408
+ return orig.makeRe(pattern, ext(def, options))
45409
+ }
45410
+
45411
+ m.braceExpand = function braceExpand (pattern, options) {
45412
+ return orig.braceExpand(pattern, ext(def, options))
45413
+ }
45414
+
45415
+ m.match = function (list, pattern, options) {
45416
+ return orig.match(list, pattern, ext(def, options))
45417
+ }
45394
45418
45395
45419
return m
45396
45420
}
45397
45421
45398
45422
Minimatch.defaults = function (def) {
45399
- if (!def || !Object.keys(def).length) return Minimatch
45400
45423
return minimatch.defaults(def).Minimatch
45401
45424
}
45402
45425
45403
45426
function minimatch (p, pattern, options) {
45404
- if (typeof pattern !== 'string') {
45405
- throw new TypeError('glob pattern string required')
45406
- }
45427
+ assertValidPattern(pattern)
45407
45428
45408
45429
if (!options) options = {}
45409
45430
@@ -45412,9 +45433,6 @@ function minimatch (p, pattern, options) {
45412
45433
return false
45413
45434
}
45414
45435
45415
- // "" only matches ""
45416
- if (pattern.trim() === '') return p === ''
45417
-
45418
45436
return new Minimatch(pattern, options).match(p)
45419
45437
}
45420
45438
@@ -45423,15 +45441,14 @@ function Minimatch (pattern, options) {
45423
45441
return new Minimatch(pattern, options)
45424
45442
}
45425
45443
45426
- if (typeof pattern !== 'string') {
45427
- throw new TypeError('glob pattern string required')
45428
- }
45444
+ assertValidPattern(pattern)
45429
45445
45430
45446
if (!options) options = {}
45447
+
45431
45448
pattern = pattern.trim()
45432
45449
45433
45450
// windows support: need to use /, not \
45434
- if (path.sep !== '/') {
45451
+ if (!options.allowWindowsEscape && path.sep !== '/') {
45435
45452
pattern = pattern.split(path.sep).join('/')
45436
45453
}
45437
45454
@@ -45442,6 +45459,7 @@ function Minimatch (pattern, options) {
45442
45459
this.negate = false
45443
45460
this.comment = false
45444
45461
this.empty = false
45462
+ this.partial = !!options.partial
45445
45463
45446
45464
// make the set of regexps etc.
45447
45465
this.make()
@@ -45451,9 +45469,6 @@ Minimatch.prototype.debug = function () {}
45451
45469
45452
45470
Minimatch.prototype.make = make
45453
45471
function make () {
45454
- // don't do it more than once.
45455
- if (this._made) return
45456
-
45457
45472
var pattern = this.pattern
45458
45473
var options = this.options
45459
45474
@@ -45473,7 +45488,7 @@ function make () {
45473
45488
// step 2: expand braces
45474
45489
var set = this.globSet = this.braceExpand()
45475
45490
45476
- if (options.debug) this.debug = console.error
45491
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
45477
45492
45478
45493
this.debug(this.pattern, set)
45479
45494
@@ -45553,19 +45568,29 @@ function braceExpand (pattern, options) {
45553
45568
pattern = typeof pattern === 'undefined'
45554
45569
? this.pattern : pattern
45555
45570
45556
- if (typeof pattern === 'undefined') {
45557
- throw new TypeError('undefined pattern')
45558
- }
45571
+ assertValidPattern(pattern)
45559
45572
45560
- if (options.nobrace ||
45561
- !pattern.match(/\{.*\}/)) {
45573
+ // Thanks to Yeting Li <https://github.com/yetingli> for
45574
+ // improving this regexp to avoid a ReDOS vulnerability.
45575
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
45562
45576
// shortcut. no need to expand.
45563
45577
return [pattern]
45564
45578
}
45565
45579
45566
45580
return expand(pattern)
45567
45581
}
45568
45582
45583
+ var MAX_PATTERN_LENGTH = 1024 * 64
45584
+ var assertValidPattern = function (pattern) {
45585
+ if (typeof pattern !== 'string') {
45586
+ throw new TypeError('invalid pattern')
45587
+ }
45588
+
45589
+ if (pattern.length > MAX_PATTERN_LENGTH) {
45590
+ throw new TypeError('pattern is too long')
45591
+ }
45592
+ }
45593
+
45569
45594
// parse a component of the expanded set.
45570
45595
// At this point, no pattern may contain "/" in it
45571
45596
// so we're going to return a 2d array, where each entry is the full
@@ -45580,14 +45605,17 @@ function braceExpand (pattern, options) {
45580
45605
Minimatch.prototype.parse = parse
45581
45606
var SUBPARSE = {}
45582
45607
function parse (pattern, isSub) {
45583
- if (pattern.length > 1024 * 64) {
45584
- throw new TypeError('pattern is too long')
45585
- }
45608
+ assertValidPattern(pattern)
45586
45609
45587
45610
var options = this.options
45588
45611
45589
45612
// shortcuts
45590
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
45613
+ if (pattern === '**') {
45614
+ if (!options.noglobstar)
45615
+ return GLOBSTAR
45616
+ else
45617
+ pattern = '*'
45618
+ }
45591
45619
if (pattern === '') return ''
45592
45620
45593
45621
var re = ''
@@ -45643,10 +45671,12 @@ function parse (pattern, isSub) {
45643
45671
}
45644
45672
45645
45673
switch (c) {
45646
- case '/':
45674
+ /* istanbul ignore next */
45675
+ case '/': {
45647
45676
// completely not allowed, even escaped.
45648
45677
// Should already be path-split by now.
45649
45678
return false
45679
+ }
45650
45680
45651
45681
case '\\':
45652
45682
clearStateChar()
@@ -45765,25 +45795,23 @@ function parse (pattern, isSub) {
45765
45795
45766
45796
// handle the case where we left a class open.
45767
45797
// "[z-a]" is valid, equivalent to "\[z-a\]"
45768
- if (inClass) {
45769
- // split where the last [ was, make sure we don't have
45770
- // an invalid re. if so, re-walk the contents of the
45771
- // would-be class to re-translate any characters that
45772
- // were passed through as-is
45773
- // TODO: It would probably be faster to determine this
45774
- // without a try/catch and a new RegExp, but it's tricky
45775
- // to do safely. For now, this is safe and works.
45776
- var cs = pattern.substring(classStart + 1, i)
45777
- try {
45778
- RegExp('[' + cs + ']')
45779
- } catch (er) {
45780
- // not a valid class!
45781
- var sp = this.parse(cs, SUBPARSE)
45782
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
45783
- hasMagic = hasMagic || sp[1]
45784
- inClass = false
45785
- continue
45786
- }
45798
+ // split where the last [ was, make sure we don't have
45799
+ // an invalid re. if so, re-walk the contents of the
45800
+ // would-be class to re-translate any characters that
45801
+ // were passed through as-is
45802
+ // TODO: It would probably be faster to determine this
45803
+ // without a try/catch and a new RegExp, but it's tricky
45804
+ // to do safely. For now, this is safe and works.
45805
+ var cs = pattern.substring(classStart + 1, i)
45806
+ try {
45807
+ RegExp('[' + cs + ']')
45808
+ } catch (er) {
45809
+ // not a valid class!
45810
+ var sp = this.parse(cs, SUBPARSE)
45811
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
45812
+ hasMagic = hasMagic || sp[1]
45813
+ inClass = false
45814
+ continue
45787
45815
}
45788
45816
45789
45817
// finish up the class.
@@ -45867,9 +45895,7 @@ function parse (pattern, isSub) {
45867
45895
// something that could conceivably capture a dot
45868
45896
var addPatternStart = false
45869
45897
switch (re.charAt(0)) {
45870
- case '.':
45871
- case '[':
45872
- case '(': addPatternStart = true
45898
+ case '[': case '.': case '(': addPatternStart = true
45873
45899
}
45874
45900
45875
45901
// Hack to work around lack of negative lookbehind in JS
@@ -45931,7 +45957,7 @@ function parse (pattern, isSub) {
45931
45957
var flags = options.nocase ? 'i' : ''
45932
45958
try {
45933
45959
var regExp = new RegExp('^' + re + '$', flags)
45934
- } catch (er) {
45960
+ } catch (er) /* istanbul ignore next - should be impossible */ {
45935
45961
// If it was an invalid regular expression, then it can't match
45936
45962
// anything. This trick looks for a character after the end of
45937
45963
// the string, which is of course impossible, except in multi-line
@@ -45989,7 +46015,7 @@ function makeRe () {
45989
46015
45990
46016
try {
45991
46017
this.regexp = new RegExp(re, flags)
45992
- } catch (ex) {
46018
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
45993
46019
this.regexp = false
45994
46020
}
45995
46021
return this.regexp
@@ -46007,8 +46033,8 @@ minimatch.match = function (list, pattern, options) {
46007
46033
return list
46008
46034
}
46009
46035
46010
- Minimatch.prototype.match = match
46011
- function match (f, partial) {
46036
+ Minimatch.prototype.match = function match (f, partial) {
46037
+ if (typeof partial === 'undefined') partial = this.partial
46012
46038
this.debug('match', f, this.pattern)
46013
46039
// short-circuit in the case of busted things.
46014
46040
// comments, etc.
@@ -46090,6 +46116,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46090
46116
46091
46117
// should be impossible.
46092
46118
// some invalid regexp stuff in the set.
46119
+ /* istanbul ignore if */
46093
46120
if (p === false) return false
46094
46121
46095
46122
if (p === GLOBSTAR) {
@@ -46163,6 +46190,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46163
46190
// no match was found.
46164
46191
// However, in partial mode, we can't say this is necessarily over.
46165
46192
// If there's more *pattern* left, then
46193
+ /* istanbul ignore if */
46166
46194
if (partial) {
46167
46195
// ran out of file
46168
46196
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -46176,11 +46204,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46176
46204
// patterns with magic have been turned into regexps.
46177
46205
var hit
46178
46206
if (typeof p === 'string') {
46179
- if (options.nocase) {
46180
- hit = f.toLowerCase() === p.toLowerCase()
46181
- } else {
46182
- hit = f === p
46183
- }
46207
+ hit = f === p
46184
46208
this.debug('string match', p, f, hit)
46185
46209
} else {
46186
46210
hit = f.match(p)
@@ -46211,16 +46235,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46211
46235
// this is ok if we're doing the match as part of
46212
46236
// a glob fs traversal.
46213
46237
return partial
46214
- } else if (pi === pl) {
46238
+ } else /* istanbul ignore else */ if (pi === pl) {
46215
46239
// ran out of pattern, still have file left.
46216
46240
// this is only acceptable if we're on the very last
46217
46241
// empty segment of a file with a trailing slash.
46218
46242
// a/* should match a/b/
46219
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
46220
- return emptyFileEnd
46243
+ return (fi === fl - 1) && (file[fi] === '')
46221
46244
}
46222
46245
46223
46246
// should be unreachable.
46247
+ /* istanbul ignore next */
46224
46248
throw new Error('wtf?')
46225
46249
}
46226
46250
0 commit comments