@@ -14086,10 +14086,10 @@ exports.getCmdPath = getCmdPath;
14086
14086
module.exports = minimatch
14087
14087
minimatch.Minimatch = Minimatch
14088
14088
14089
- var path = { sep: '/' }
14090
- try {
14091
- path = __webpack_require__(622)
14092
- } catch (er) {}
14089
+ var path = (function () { try { return __webpack_require__(622) } catch (e) {}}()) || {
14090
+ sep: '/'
14091
+ }
14092
+ minimatch.sep = path.sep
14093
14093
14094
14094
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
14095
14095
var expand = __webpack_require__(850)
@@ -14141,43 +14141,64 @@ function filter (pattern, options) {
14141
14141
}
14142
14142
14143
14143
function ext (a, b) {
14144
- a = a || {}
14145
14144
b = b || {}
14146
14145
var t = {}
14147
- Object.keys(b).forEach(function (k) {
14148
- t[k] = b[k]
14149
- })
14150
14146
Object.keys(a).forEach(function (k) {
14151
14147
t[k] = a[k]
14152
14148
})
14149
+ Object.keys(b).forEach(function (k) {
14150
+ t[k] = b[k]
14151
+ })
14153
14152
return t
14154
14153
}
14155
14154
14156
14155
minimatch.defaults = function (def) {
14157
- if (!def || !Object.keys(def).length) return minimatch
14156
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
14157
+ return minimatch
14158
+ }
14158
14159
14159
14160
var orig = minimatch
14160
14161
14161
14162
var m = function minimatch (p, pattern, options) {
14162
- return orig.minimatch (p, pattern, ext(def, options))
14163
+ return orig(p, pattern, ext(def, options))
14163
14164
}
14164
14165
14165
14166
m.Minimatch = function Minimatch (pattern, options) {
14166
14167
return new orig.Minimatch(pattern, ext(def, options))
14167
14168
}
14169
+ m.Minimatch.defaults = function defaults (options) {
14170
+ return orig.defaults(ext(def, options)).Minimatch
14171
+ }
14172
+
14173
+ m.filter = function filter (pattern, options) {
14174
+ return orig.filter(pattern, ext(def, options))
14175
+ }
14176
+
14177
+ m.defaults = function defaults (options) {
14178
+ return orig.defaults(ext(def, options))
14179
+ }
14180
+
14181
+ m.makeRe = function makeRe (pattern, options) {
14182
+ return orig.makeRe(pattern, ext(def, options))
14183
+ }
14184
+
14185
+ m.braceExpand = function braceExpand (pattern, options) {
14186
+ return orig.braceExpand(pattern, ext(def, options))
14187
+ }
14188
+
14189
+ m.match = function (list, pattern, options) {
14190
+ return orig.match(list, pattern, ext(def, options))
14191
+ }
14168
14192
14169
14193
return m
14170
14194
}
14171
14195
14172
14196
Minimatch.defaults = function (def) {
14173
- if (!def || !Object.keys(def).length) return Minimatch
14174
14197
return minimatch.defaults(def).Minimatch
14175
14198
}
14176
14199
14177
14200
function minimatch (p, pattern, options) {
14178
- if (typeof pattern !== 'string') {
14179
- throw new TypeError('glob pattern string required')
14180
- }
14201
+ assertValidPattern(pattern)
14181
14202
14182
14203
if (!options) options = {}
14183
14204
@@ -14186,9 +14207,6 @@ function minimatch (p, pattern, options) {
14186
14207
return false
14187
14208
}
14188
14209
14189
- // "" only matches ""
14190
- if (pattern.trim() === '') return p === ''
14191
-
14192
14210
return new Minimatch(pattern, options).match(p)
14193
14211
}
14194
14212
@@ -14197,15 +14215,14 @@ function Minimatch (pattern, options) {
14197
14215
return new Minimatch(pattern, options)
14198
14216
}
14199
14217
14200
- if (typeof pattern !== 'string') {
14201
- throw new TypeError('glob pattern string required')
14202
- }
14218
+ assertValidPattern(pattern)
14203
14219
14204
14220
if (!options) options = {}
14221
+
14205
14222
pattern = pattern.trim()
14206
14223
14207
14224
// windows support: need to use /, not \
14208
- if (path.sep !== '/') {
14225
+ if (!options.allowWindowsEscape && path.sep !== '/') {
14209
14226
pattern = pattern.split(path.sep).join('/')
14210
14227
}
14211
14228
@@ -14216,6 +14233,7 @@ function Minimatch (pattern, options) {
14216
14233
this.negate = false
14217
14234
this.comment = false
14218
14235
this.empty = false
14236
+ this.partial = !!options.partial
14219
14237
14220
14238
// make the set of regexps etc.
14221
14239
this.make()
@@ -14225,9 +14243,6 @@ Minimatch.prototype.debug = function () {}
14225
14243
14226
14244
Minimatch.prototype.make = make
14227
14245
function make () {
14228
- // don't do it more than once.
14229
- if (this._made) return
14230
-
14231
14246
var pattern = this.pattern
14232
14247
var options = this.options
14233
14248
@@ -14247,7 +14262,7 @@ function make () {
14247
14262
// step 2: expand braces
14248
14263
var set = this.globSet = this.braceExpand()
14249
14264
14250
- if (options.debug) this.debug = console.error
14265
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
14251
14266
14252
14267
this.debug(this.pattern, set)
14253
14268
@@ -14327,19 +14342,29 @@ function braceExpand (pattern, options) {
14327
14342
pattern = typeof pattern === 'undefined'
14328
14343
? this.pattern : pattern
14329
14344
14330
- if (typeof pattern === 'undefined') {
14331
- throw new TypeError('undefined pattern')
14332
- }
14345
+ assertValidPattern(pattern)
14333
14346
14334
- if (options.nobrace ||
14335
- !pattern.match(/\{.*\}/)) {
14347
+ // Thanks to Yeting Li <https://github.com/yetingli> for
14348
+ // improving this regexp to avoid a ReDOS vulnerability.
14349
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
14336
14350
// shortcut. no need to expand.
14337
14351
return [pattern]
14338
14352
}
14339
14353
14340
14354
return expand(pattern)
14341
14355
}
14342
14356
14357
+ var MAX_PATTERN_LENGTH = 1024 * 64
14358
+ var assertValidPattern = function (pattern) {
14359
+ if (typeof pattern !== 'string') {
14360
+ throw new TypeError('invalid pattern')
14361
+ }
14362
+
14363
+ if (pattern.length > MAX_PATTERN_LENGTH) {
14364
+ throw new TypeError('pattern is too long')
14365
+ }
14366
+ }
14367
+
14343
14368
// parse a component of the expanded set.
14344
14369
// At this point, no pattern may contain "/" in it
14345
14370
// so we're going to return a 2d array, where each entry is the full
@@ -14354,14 +14379,17 @@ function braceExpand (pattern, options) {
14354
14379
Minimatch.prototype.parse = parse
14355
14380
var SUBPARSE = {}
14356
14381
function parse (pattern, isSub) {
14357
- if (pattern.length > 1024 * 64) {
14358
- throw new TypeError('pattern is too long')
14359
- }
14382
+ assertValidPattern(pattern)
14360
14383
14361
14384
var options = this.options
14362
14385
14363
14386
// shortcuts
14364
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
14387
+ if (pattern === '**') {
14388
+ if (!options.noglobstar)
14389
+ return GLOBSTAR
14390
+ else
14391
+ pattern = '*'
14392
+ }
14365
14393
if (pattern === '') return ''
14366
14394
14367
14395
var re = ''
@@ -14417,10 +14445,12 @@ function parse (pattern, isSub) {
14417
14445
}
14418
14446
14419
14447
switch (c) {
14420
- case '/':
14448
+ /* istanbul ignore next */
14449
+ case '/': {
14421
14450
// completely not allowed, even escaped.
14422
14451
// Should already be path-split by now.
14423
14452
return false
14453
+ }
14424
14454
14425
14455
case '\\':
14426
14456
clearStateChar()
@@ -14539,25 +14569,23 @@ function parse (pattern, isSub) {
14539
14569
14540
14570
// handle the case where we left a class open.
14541
14571
// "[z-a]" is valid, equivalent to "\[z-a\]"
14542
- if (inClass) {
14543
- // split where the last [ was, make sure we don't have
14544
- // an invalid re. if so, re-walk the contents of the
14545
- // would-be class to re-translate any characters that
14546
- // were passed through as-is
14547
- // TODO: It would probably be faster to determine this
14548
- // without a try/catch and a new RegExp, but it's tricky
14549
- // to do safely. For now, this is safe and works.
14550
- var cs = pattern.substring(classStart + 1, i)
14551
- try {
14552
- RegExp('[' + cs + ']')
14553
- } catch (er) {
14554
- // not a valid class!
14555
- var sp = this.parse(cs, SUBPARSE)
14556
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
14557
- hasMagic = hasMagic || sp[1]
14558
- inClass = false
14559
- continue
14560
- }
14572
+ // split where the last [ was, make sure we don't have
14573
+ // an invalid re. if so, re-walk the contents of the
14574
+ // would-be class to re-translate any characters that
14575
+ // were passed through as-is
14576
+ // TODO: It would probably be faster to determine this
14577
+ // without a try/catch and a new RegExp, but it's tricky
14578
+ // to do safely. For now, this is safe and works.
14579
+ var cs = pattern.substring(classStart + 1, i)
14580
+ try {
14581
+ RegExp('[' + cs + ']')
14582
+ } catch (er) {
14583
+ // not a valid class!
14584
+ var sp = this.parse(cs, SUBPARSE)
14585
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
14586
+ hasMagic = hasMagic || sp[1]
14587
+ inClass = false
14588
+ continue
14561
14589
}
14562
14590
14563
14591
// finish up the class.
@@ -14641,9 +14669,7 @@ function parse (pattern, isSub) {
14641
14669
// something that could conceivably capture a dot
14642
14670
var addPatternStart = false
14643
14671
switch (re.charAt(0)) {
14644
- case '.':
14645
- case '[':
14646
- case '(': addPatternStart = true
14672
+ case '[': case '.': case '(': addPatternStart = true
14647
14673
}
14648
14674
14649
14675
// Hack to work around lack of negative lookbehind in JS
@@ -14705,7 +14731,7 @@ function parse (pattern, isSub) {
14705
14731
var flags = options.nocase ? 'i' : ''
14706
14732
try {
14707
14733
var regExp = new RegExp('^' + re + '$', flags)
14708
- } catch (er) {
14734
+ } catch (er) /* istanbul ignore next - should be impossible */ {
14709
14735
// If it was an invalid regular expression, then it can't match
14710
14736
// anything. This trick looks for a character after the end of
14711
14737
// the string, which is of course impossible, except in multi-line
@@ -14763,7 +14789,7 @@ function makeRe () {
14763
14789
14764
14790
try {
14765
14791
this.regexp = new RegExp(re, flags)
14766
- } catch (ex) {
14792
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
14767
14793
this.regexp = false
14768
14794
}
14769
14795
return this.regexp
@@ -14781,8 +14807,8 @@ minimatch.match = function (list, pattern, options) {
14781
14807
return list
14782
14808
}
14783
14809
14784
- Minimatch.prototype.match = match
14785
- function match (f, partial) {
14810
+ Minimatch.prototype.match = function match (f, partial) {
14811
+ if (typeof partial === 'undefined') partial = this.partial
14786
14812
this.debug('match', f, this.pattern)
14787
14813
// short-circuit in the case of busted things.
14788
14814
// comments, etc.
@@ -14864,6 +14890,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
14864
14890
14865
14891
// should be impossible.
14866
14892
// some invalid regexp stuff in the set.
14893
+ /* istanbul ignore if */
14867
14894
if (p === false) return false
14868
14895
14869
14896
if (p === GLOBSTAR) {
@@ -14937,6 +14964,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
14937
14964
// no match was found.
14938
14965
// However, in partial mode, we can't say this is necessarily over.
14939
14966
// If there's more *pattern* left, then
14967
+ /* istanbul ignore if */
14940
14968
if (partial) {
14941
14969
// ran out of file
14942
14970
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -14950,11 +14978,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
14950
14978
// patterns with magic have been turned into regexps.
14951
14979
var hit
14952
14980
if (typeof p === 'string') {
14953
- if (options.nocase) {
14954
- hit = f.toLowerCase() === p.toLowerCase()
14955
- } else {
14956
- hit = f === p
14957
- }
14981
+ hit = f === p
14958
14982
this.debug('string match', p, f, hit)
14959
14983
} else {
14960
14984
hit = f.match(p)
@@ -14985,16 +15009,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
14985
15009
// this is ok if we're doing the match as part of
14986
15010
// a glob fs traversal.
14987
15011
return partial
14988
- } else if (pi === pl) {
15012
+ } else /* istanbul ignore else */ if (pi === pl) {
14989
15013
// ran out of pattern, still have file left.
14990
15014
// this is only acceptable if we're on the very last
14991
15015
// empty segment of a file with a trailing slash.
14992
15016
// a/* should match a/b/
14993
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
14994
- return emptyFileEnd
15017
+ return (fi === fl - 1) && (file[fi] === '')
14995
15018
}
14996
15019
14997
15020
// should be unreachable.
15021
+ /* istanbul ignore next */
14998
15022
throw new Error('wtf?')
14999
15023
}
15000
15024
0 commit comments