@@ -45304,10 +45304,10 @@ function populateMaps (extensions, types) {
45304
45304
module.exports = minimatch
45305
45305
minimatch.Minimatch = Minimatch
45306
45306
45307
- var path = { sep: '/' }
45308
- try {
45309
- path = __nccwpck_require__(1017)
45310
- } catch (er) {}
45307
+ var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || {
45308
+ sep: '/'
45309
+ }
45310
+ minimatch.sep = path.sep
45311
45311
45312
45312
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
45313
45313
var expand = __nccwpck_require__(3717)
@@ -45359,43 +45359,64 @@ function filter (pattern, options) {
45359
45359
}
45360
45360
45361
45361
function ext (a, b) {
45362
- a = a || {}
45363
45362
b = b || {}
45364
45363
var t = {}
45365
- Object.keys(b).forEach(function (k) {
45366
- t[k] = b[k]
45367
- })
45368
45364
Object.keys(a).forEach(function (k) {
45369
45365
t[k] = a[k]
45370
45366
})
45367
+ Object.keys(b).forEach(function (k) {
45368
+ t[k] = b[k]
45369
+ })
45371
45370
return t
45372
45371
}
45373
45372
45374
45373
minimatch.defaults = function (def) {
45375
- if (!def || !Object.keys(def).length) return minimatch
45374
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
45375
+ return minimatch
45376
+ }
45376
45377
45377
45378
var orig = minimatch
45378
45379
45379
45380
var m = function minimatch (p, pattern, options) {
45380
- return orig.minimatch (p, pattern, ext(def, options))
45381
+ return orig(p, pattern, ext(def, options))
45381
45382
}
45382
45383
45383
45384
m.Minimatch = function Minimatch (pattern, options) {
45384
45385
return new orig.Minimatch(pattern, ext(def, options))
45385
45386
}
45387
+ m.Minimatch.defaults = function defaults (options) {
45388
+ return orig.defaults(ext(def, options)).Minimatch
45389
+ }
45390
+
45391
+ m.filter = function filter (pattern, options) {
45392
+ return orig.filter(pattern, ext(def, options))
45393
+ }
45394
+
45395
+ m.defaults = function defaults (options) {
45396
+ return orig.defaults(ext(def, options))
45397
+ }
45398
+
45399
+ m.makeRe = function makeRe (pattern, options) {
45400
+ return orig.makeRe(pattern, ext(def, options))
45401
+ }
45402
+
45403
+ m.braceExpand = function braceExpand (pattern, options) {
45404
+ return orig.braceExpand(pattern, ext(def, options))
45405
+ }
45406
+
45407
+ m.match = function (list, pattern, options) {
45408
+ return orig.match(list, pattern, ext(def, options))
45409
+ }
45386
45410
45387
45411
return m
45388
45412
}
45389
45413
45390
45414
Minimatch.defaults = function (def) {
45391
- if (!def || !Object.keys(def).length) return Minimatch
45392
45415
return minimatch.defaults(def).Minimatch
45393
45416
}
45394
45417
45395
45418
function minimatch (p, pattern, options) {
45396
- if (typeof pattern !== 'string') {
45397
- throw new TypeError('glob pattern string required')
45398
- }
45419
+ assertValidPattern(pattern)
45399
45420
45400
45421
if (!options) options = {}
45401
45422
@@ -45404,9 +45425,6 @@ function minimatch (p, pattern, options) {
45404
45425
return false
45405
45426
}
45406
45427
45407
- // "" only matches ""
45408
- if (pattern.trim() === '') return p === ''
45409
-
45410
45428
return new Minimatch(pattern, options).match(p)
45411
45429
}
45412
45430
@@ -45415,15 +45433,14 @@ function Minimatch (pattern, options) {
45415
45433
return new Minimatch(pattern, options)
45416
45434
}
45417
45435
45418
- if (typeof pattern !== 'string') {
45419
- throw new TypeError('glob pattern string required')
45420
- }
45436
+ assertValidPattern(pattern)
45421
45437
45422
45438
if (!options) options = {}
45439
+
45423
45440
pattern = pattern.trim()
45424
45441
45425
45442
// windows support: need to use /, not \
45426
- if (path.sep !== '/') {
45443
+ if (!options.allowWindowsEscape && path.sep !== '/') {
45427
45444
pattern = pattern.split(path.sep).join('/')
45428
45445
}
45429
45446
@@ -45434,6 +45451,7 @@ function Minimatch (pattern, options) {
45434
45451
this.negate = false
45435
45452
this.comment = false
45436
45453
this.empty = false
45454
+ this.partial = !!options.partial
45437
45455
45438
45456
// make the set of regexps etc.
45439
45457
this.make()
@@ -45443,9 +45461,6 @@ Minimatch.prototype.debug = function () {}
45443
45461
45444
45462
Minimatch.prototype.make = make
45445
45463
function make () {
45446
- // don't do it more than once.
45447
- if (this._made) return
45448
-
45449
45464
var pattern = this.pattern
45450
45465
var options = this.options
45451
45466
@@ -45465,7 +45480,7 @@ function make () {
45465
45480
// step 2: expand braces
45466
45481
var set = this.globSet = this.braceExpand()
45467
45482
45468
- if (options.debug) this.debug = console.error
45483
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
45469
45484
45470
45485
this.debug(this.pattern, set)
45471
45486
@@ -45545,19 +45560,29 @@ function braceExpand (pattern, options) {
45545
45560
pattern = typeof pattern === 'undefined'
45546
45561
? this.pattern : pattern
45547
45562
45548
- if (typeof pattern === 'undefined') {
45549
- throw new TypeError('undefined pattern')
45550
- }
45563
+ assertValidPattern(pattern)
45551
45564
45552
- if (options.nobrace ||
45553
- !pattern.match(/\{.*\}/)) {
45565
+ // Thanks to Yeting Li <https://github.com/yetingli> for
45566
+ // improving this regexp to avoid a ReDOS vulnerability.
45567
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
45554
45568
// shortcut. no need to expand.
45555
45569
return [pattern]
45556
45570
}
45557
45571
45558
45572
return expand(pattern)
45559
45573
}
45560
45574
45575
+ var MAX_PATTERN_LENGTH = 1024 * 64
45576
+ var assertValidPattern = function (pattern) {
45577
+ if (typeof pattern !== 'string') {
45578
+ throw new TypeError('invalid pattern')
45579
+ }
45580
+
45581
+ if (pattern.length > MAX_PATTERN_LENGTH) {
45582
+ throw new TypeError('pattern is too long')
45583
+ }
45584
+ }
45585
+
45561
45586
// parse a component of the expanded set.
45562
45587
// At this point, no pattern may contain "/" in it
45563
45588
// so we're going to return a 2d array, where each entry is the full
@@ -45572,14 +45597,17 @@ function braceExpand (pattern, options) {
45572
45597
Minimatch.prototype.parse = parse
45573
45598
var SUBPARSE = {}
45574
45599
function parse (pattern, isSub) {
45575
- if (pattern.length > 1024 * 64) {
45576
- throw new TypeError('pattern is too long')
45577
- }
45600
+ assertValidPattern(pattern)
45578
45601
45579
45602
var options = this.options
45580
45603
45581
45604
// shortcuts
45582
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
45605
+ if (pattern === '**') {
45606
+ if (!options.noglobstar)
45607
+ return GLOBSTAR
45608
+ else
45609
+ pattern = '*'
45610
+ }
45583
45611
if (pattern === '') return ''
45584
45612
45585
45613
var re = ''
@@ -45635,10 +45663,12 @@ function parse (pattern, isSub) {
45635
45663
}
45636
45664
45637
45665
switch (c) {
45638
- case '/':
45666
+ /* istanbul ignore next */
45667
+ case '/': {
45639
45668
// completely not allowed, even escaped.
45640
45669
// Should already be path-split by now.
45641
45670
return false
45671
+ }
45642
45672
45643
45673
case '\\':
45644
45674
clearStateChar()
@@ -45757,25 +45787,23 @@ function parse (pattern, isSub) {
45757
45787
45758
45788
// handle the case where we left a class open.
45759
45789
// "[z-a]" is valid, equivalent to "\[z-a\]"
45760
- if (inClass) {
45761
- // split where the last [ was, make sure we don't have
45762
- // an invalid re. if so, re-walk the contents of the
45763
- // would-be class to re-translate any characters that
45764
- // were passed through as-is
45765
- // TODO: It would probably be faster to determine this
45766
- // without a try/catch and a new RegExp, but it's tricky
45767
- // to do safely. For now, this is safe and works.
45768
- var cs = pattern.substring(classStart + 1, i)
45769
- try {
45770
- RegExp('[' + cs + ']')
45771
- } catch (er) {
45772
- // not a valid class!
45773
- var sp = this.parse(cs, SUBPARSE)
45774
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
45775
- hasMagic = hasMagic || sp[1]
45776
- inClass = false
45777
- continue
45778
- }
45790
+ // split where the last [ was, make sure we don't have
45791
+ // an invalid re. if so, re-walk the contents of the
45792
+ // would-be class to re-translate any characters that
45793
+ // were passed through as-is
45794
+ // TODO: It would probably be faster to determine this
45795
+ // without a try/catch and a new RegExp, but it's tricky
45796
+ // to do safely. For now, this is safe and works.
45797
+ var cs = pattern.substring(classStart + 1, i)
45798
+ try {
45799
+ RegExp('[' + cs + ']')
45800
+ } catch (er) {
45801
+ // not a valid class!
45802
+ var sp = this.parse(cs, SUBPARSE)
45803
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
45804
+ hasMagic = hasMagic || sp[1]
45805
+ inClass = false
45806
+ continue
45779
45807
}
45780
45808
45781
45809
// finish up the class.
@@ -45859,9 +45887,7 @@ function parse (pattern, isSub) {
45859
45887
// something that could conceivably capture a dot
45860
45888
var addPatternStart = false
45861
45889
switch (re.charAt(0)) {
45862
- case '.':
45863
- case '[':
45864
- case '(': addPatternStart = true
45890
+ case '[': case '.': case '(': addPatternStart = true
45865
45891
}
45866
45892
45867
45893
// Hack to work around lack of negative lookbehind in JS
@@ -45923,7 +45949,7 @@ function parse (pattern, isSub) {
45923
45949
var flags = options.nocase ? 'i' : ''
45924
45950
try {
45925
45951
var regExp = new RegExp('^' + re + '$', flags)
45926
- } catch (er) {
45952
+ } catch (er) /* istanbul ignore next - should be impossible */ {
45927
45953
// If it was an invalid regular expression, then it can't match
45928
45954
// anything. This trick looks for a character after the end of
45929
45955
// the string, which is of course impossible, except in multi-line
@@ -45981,7 +46007,7 @@ function makeRe () {
45981
46007
45982
46008
try {
45983
46009
this.regexp = new RegExp(re, flags)
45984
- } catch (ex) {
46010
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
45985
46011
this.regexp = false
45986
46012
}
45987
46013
return this.regexp
@@ -45999,8 +46025,8 @@ minimatch.match = function (list, pattern, options) {
45999
46025
return list
46000
46026
}
46001
46027
46002
- Minimatch.prototype.match = match
46003
- function match (f, partial) {
46028
+ Minimatch.prototype.match = function match (f, partial) {
46029
+ if (typeof partial === 'undefined') partial = this.partial
46004
46030
this.debug('match', f, this.pattern)
46005
46031
// short-circuit in the case of busted things.
46006
46032
// comments, etc.
@@ -46082,6 +46108,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46082
46108
46083
46109
// should be impossible.
46084
46110
// some invalid regexp stuff in the set.
46111
+ /* istanbul ignore if */
46085
46112
if (p === false) return false
46086
46113
46087
46114
if (p === GLOBSTAR) {
@@ -46155,6 +46182,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46155
46182
// no match was found.
46156
46183
// However, in partial mode, we can't say this is necessarily over.
46157
46184
// If there's more *pattern* left, then
46185
+ /* istanbul ignore if */
46158
46186
if (partial) {
46159
46187
// ran out of file
46160
46188
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -46168,11 +46196,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46168
46196
// patterns with magic have been turned into regexps.
46169
46197
var hit
46170
46198
if (typeof p === 'string') {
46171
- if (options.nocase) {
46172
- hit = f.toLowerCase() === p.toLowerCase()
46173
- } else {
46174
- hit = f === p
46175
- }
46199
+ hit = f === p
46176
46200
this.debug('string match', p, f, hit)
46177
46201
} else {
46178
46202
hit = f.match(p)
@@ -46203,16 +46227,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
46203
46227
// this is ok if we're doing the match as part of
46204
46228
// a glob fs traversal.
46205
46229
return partial
46206
- } else if (pi === pl) {
46230
+ } else /* istanbul ignore else */ if (pi === pl) {
46207
46231
// ran out of pattern, still have file left.
46208
46232
// this is only acceptable if we're on the very last
46209
46233
// empty segment of a file with a trailing slash.
46210
46234
// a/* should match a/b/
46211
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
46212
- return emptyFileEnd
46235
+ return (fi === fl - 1) && (file[fi] === '')
46213
46236
}
46214
46237
46215
46238
// should be unreachable.
46239
+ /* istanbul ignore next */
46216
46240
throw new Error('wtf?')
46217
46241
}
46218
46242
0 commit comments