@@ -107350,10 +107350,10 @@ module.exports = mime;
107350107350module.exports = minimatch
107351107351minimatch.Minimatch = Minimatch
107352107352
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
107357107357
107358107358var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
107359107359var expand = __nccwpck_require__(33717)
@@ -107405,43 +107405,64 @@ function filter (pattern, options) {
107405107405}
107406107406
107407107407function ext (a, b) {
107408- a = a || {}
107409107408 b = b || {}
107410107409 var t = {}
107411- Object.keys(b).forEach(function (k) {
107412- t[k] = b[k]
107413- })
107414107410 Object.keys(a).forEach(function (k) {
107415107411 t[k] = a[k]
107416107412 })
107413+ Object.keys(b).forEach(function (k) {
107414+ t[k] = b[k]
107415+ })
107417107416 return t
107418107417}
107419107418
107420107419minimatch.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+ }
107422107423
107423107424 var orig = minimatch
107424107425
107425107426 var m = function minimatch (p, pattern, options) {
107426- return orig.minimatch (p, pattern, ext(def, options))
107427+ return orig(p, pattern, ext(def, options))
107427107428 }
107428107429
107429107430 m.Minimatch = function Minimatch (pattern, options) {
107430107431 return new orig.Minimatch(pattern, ext(def, options))
107431107432 }
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+ }
107432107456
107433107457 return m
107434107458}
107435107459
107436107460Minimatch.defaults = function (def) {
107437- if (!def || !Object.keys(def).length) return Minimatch
107438107461 return minimatch.defaults(def).Minimatch
107439107462}
107440107463
107441107464function minimatch (p, pattern, options) {
107442- if (typeof pattern !== 'string') {
107443- throw new TypeError('glob pattern string required')
107444- }
107465+ assertValidPattern(pattern)
107445107466
107446107467 if (!options) options = {}
107447107468
@@ -107450,9 +107471,6 @@ function minimatch (p, pattern, options) {
107450107471 return false
107451107472 }
107452107473
107453- // "" only matches ""
107454- if (pattern.trim() === '') return p === ''
107455-
107456107474 return new Minimatch(pattern, options).match(p)
107457107475}
107458107476
@@ -107461,15 +107479,14 @@ function Minimatch (pattern, options) {
107461107479 return new Minimatch(pattern, options)
107462107480 }
107463107481
107464- if (typeof pattern !== 'string') {
107465- throw new TypeError('glob pattern string required')
107466- }
107482+ assertValidPattern(pattern)
107467107483
107468107484 if (!options) options = {}
107485+
107469107486 pattern = pattern.trim()
107470107487
107471107488 // windows support: need to use /, not \
107472- if (path.sep !== '/') {
107489+ if (!options.allowWindowsEscape && path.sep !== '/') {
107473107490 pattern = pattern.split(path.sep).join('/')
107474107491 }
107475107492
@@ -107480,6 +107497,7 @@ function Minimatch (pattern, options) {
107480107497 this.negate = false
107481107498 this.comment = false
107482107499 this.empty = false
107500+ this.partial = !!options.partial
107483107501
107484107502 // make the set of regexps etc.
107485107503 this.make()
@@ -107489,9 +107507,6 @@ Minimatch.prototype.debug = function () {}
107489107507
107490107508Minimatch.prototype.make = make
107491107509function make () {
107492- // don't do it more than once.
107493- if (this._made) return
107494-
107495107510 var pattern = this.pattern
107496107511 var options = this.options
107497107512
@@ -107511,7 +107526,7 @@ function make () {
107511107526 // step 2: expand braces
107512107527 var set = this.globSet = this.braceExpand()
107513107528
107514- if (options.debug) this.debug = console.error
107529+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
107515107530
107516107531 this.debug(this.pattern, set)
107517107532
@@ -107591,19 +107606,29 @@ function braceExpand (pattern, options) {
107591107606 pattern = typeof pattern === 'undefined'
107592107607 ? this.pattern : pattern
107593107608
107594- if (typeof pattern === 'undefined') {
107595- throw new TypeError('undefined pattern')
107596- }
107609+ assertValidPattern(pattern)
107597107610
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)) {
107600107614 // shortcut. no need to expand.
107601107615 return [pattern]
107602107616 }
107603107617
107604107618 return expand(pattern)
107605107619}
107606107620
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+
107607107632// parse a component of the expanded set.
107608107633// At this point, no pattern may contain "/" in it
107609107634// so we're going to return a 2d array, where each entry is the full
@@ -107618,14 +107643,17 @@ function braceExpand (pattern, options) {
107618107643Minimatch.prototype.parse = parse
107619107644var SUBPARSE = {}
107620107645function parse (pattern, isSub) {
107621- if (pattern.length > 1024 * 64) {
107622- throw new TypeError('pattern is too long')
107623- }
107646+ assertValidPattern(pattern)
107624107647
107625107648 var options = this.options
107626107649
107627107650 // shortcuts
107628- if (!options.noglobstar && pattern === '**') return GLOBSTAR
107651+ if (pattern === '**') {
107652+ if (!options.noglobstar)
107653+ return GLOBSTAR
107654+ else
107655+ pattern = '*'
107656+ }
107629107657 if (pattern === '') return ''
107630107658
107631107659 var re = ''
@@ -107681,10 +107709,12 @@ function parse (pattern, isSub) {
107681107709 }
107682107710
107683107711 switch (c) {
107684- case '/':
107712+ /* istanbul ignore next */
107713+ case '/': {
107685107714 // completely not allowed, even escaped.
107686107715 // Should already be path-split by now.
107687107716 return false
107717+ }
107688107718
107689107719 case '\\':
107690107720 clearStateChar()
@@ -107803,25 +107833,23 @@ function parse (pattern, isSub) {
107803107833
107804107834 // handle the case where we left a class open.
107805107835 // "[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
107825107853 }
107826107854
107827107855 // finish up the class.
@@ -107905,9 +107933,7 @@ function parse (pattern, isSub) {
107905107933 // something that could conceivably capture a dot
107906107934 var addPatternStart = false
107907107935 switch (re.charAt(0)) {
107908- case '.':
107909- case '[':
107910- case '(': addPatternStart = true
107936+ case '[': case '.': case '(': addPatternStart = true
107911107937 }
107912107938
107913107939 // Hack to work around lack of negative lookbehind in JS
@@ -107969,7 +107995,7 @@ function parse (pattern, isSub) {
107969107995 var flags = options.nocase ? 'i' : ''
107970107996 try {
107971107997 var regExp = new RegExp('^' + re + '$', flags)
107972- } catch (er) {
107998+ } catch (er) /* istanbul ignore next - should be impossible */ {
107973107999 // If it was an invalid regular expression, then it can't match
107974108000 // anything. This trick looks for a character after the end of
107975108001 // the string, which is of course impossible, except in multi-line
@@ -108027,7 +108053,7 @@ function makeRe () {
108027108053
108028108054 try {
108029108055 this.regexp = new RegExp(re, flags)
108030- } catch (ex) {
108056+ } catch (ex) /* istanbul ignore next - should be impossible */ {
108031108057 this.regexp = false
108032108058 }
108033108059 return this.regexp
@@ -108045,8 +108071,8 @@ minimatch.match = function (list, pattern, options) {
108045108071 return list
108046108072}
108047108073
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
108050108076 this.debug('match', f, this.pattern)
108051108077 // short-circuit in the case of busted things.
108052108078 // comments, etc.
@@ -108128,6 +108154,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108128108154
108129108155 // should be impossible.
108130108156 // some invalid regexp stuff in the set.
108157+ /* istanbul ignore if */
108131108158 if (p === false) return false
108132108159
108133108160 if (p === GLOBSTAR) {
@@ -108201,6 +108228,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108201108228 // no match was found.
108202108229 // However, in partial mode, we can't say this is necessarily over.
108203108230 // If there's more *pattern* left, then
108231+ /* istanbul ignore if */
108204108232 if (partial) {
108205108233 // ran out of file
108206108234 this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -108214,11 +108242,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108214108242 // patterns with magic have been turned into regexps.
108215108243 var hit
108216108244 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
108222108246 this.debug('string match', p, f, hit)
108223108247 } else {
108224108248 hit = f.match(p)
@@ -108249,16 +108273,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
108249108273 // this is ok if we're doing the match as part of
108250108274 // a glob fs traversal.
108251108275 return partial
108252- } else if (pi === pl) {
108276+ } else /* istanbul ignore else */ if (pi === pl) {
108253108277 // ran out of pattern, still have file left.
108254108278 // this is only acceptable if we're on the very last
108255108279 // empty segment of a file with a trailing slash.
108256108280 // a/* should match a/b/
108257- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
108258- return emptyFileEnd
108281+ return (fi === fl - 1) && (file[fi] === '')
108259108282 }
108260108283
108261108284 // should be unreachable.
108285+ /* istanbul ignore next */
108262108286 throw new Error('wtf?')
108263108287}
108264108288
0 commit comments