@@ -53331,10 +53331,10 @@ function populateMaps (extensions, types) {
5333153331module.exports = minimatch
5333253332minimatch.Minimatch = Minimatch
5333353333
53334- var path = { sep: '/' }
53335- try {
53336- path = __nccwpck_require__(1017)
53337- } catch (er) {}
53334+ var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || {
53335+ sep: '/'
53336+ }
53337+ minimatch.sep = path.sep
5333853338
5333953339var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
5334053340var expand = __nccwpck_require__(3717)
@@ -53386,43 +53386,64 @@ function filter (pattern, options) {
5338653386}
5338753387
5338853388function ext (a, b) {
53389- a = a || {}
5339053389 b = b || {}
5339153390 var t = {}
53392- Object.keys(b).forEach(function (k) {
53393- t[k] = b[k]
53394- })
5339553391 Object.keys(a).forEach(function (k) {
5339653392 t[k] = a[k]
5339753393 })
53394+ Object.keys(b).forEach(function (k) {
53395+ t[k] = b[k]
53396+ })
5339853397 return t
5339953398}
5340053399
5340153400minimatch.defaults = function (def) {
53402- if (!def || !Object.keys(def).length) return minimatch
53401+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
53402+ return minimatch
53403+ }
5340353404
5340453405 var orig = minimatch
5340553406
5340653407 var m = function minimatch (p, pattern, options) {
53407- return orig.minimatch (p, pattern, ext(def, options))
53408+ return orig(p, pattern, ext(def, options))
5340853409 }
5340953410
5341053411 m.Minimatch = function Minimatch (pattern, options) {
5341153412 return new orig.Minimatch(pattern, ext(def, options))
5341253413 }
53414+ m.Minimatch.defaults = function defaults (options) {
53415+ return orig.defaults(ext(def, options)).Minimatch
53416+ }
53417+
53418+ m.filter = function filter (pattern, options) {
53419+ return orig.filter(pattern, ext(def, options))
53420+ }
53421+
53422+ m.defaults = function defaults (options) {
53423+ return orig.defaults(ext(def, options))
53424+ }
53425+
53426+ m.makeRe = function makeRe (pattern, options) {
53427+ return orig.makeRe(pattern, ext(def, options))
53428+ }
53429+
53430+ m.braceExpand = function braceExpand (pattern, options) {
53431+ return orig.braceExpand(pattern, ext(def, options))
53432+ }
53433+
53434+ m.match = function (list, pattern, options) {
53435+ return orig.match(list, pattern, ext(def, options))
53436+ }
5341353437
5341453438 return m
5341553439}
5341653440
5341753441Minimatch.defaults = function (def) {
53418- if (!def || !Object.keys(def).length) return Minimatch
5341953442 return minimatch.defaults(def).Minimatch
5342053443}
5342153444
5342253445function minimatch (p, pattern, options) {
53423- if (typeof pattern !== 'string') {
53424- throw new TypeError('glob pattern string required')
53425- }
53446+ assertValidPattern(pattern)
5342653447
5342753448 if (!options) options = {}
5342853449
@@ -53431,9 +53452,6 @@ function minimatch (p, pattern, options) {
5343153452 return false
5343253453 }
5343353454
53434- // "" only matches ""
53435- if (pattern.trim() === '') return p === ''
53436-
5343753455 return new Minimatch(pattern, options).match(p)
5343853456}
5343953457
@@ -53442,15 +53460,14 @@ function Minimatch (pattern, options) {
5344253460 return new Minimatch(pattern, options)
5344353461 }
5344453462
53445- if (typeof pattern !== 'string') {
53446- throw new TypeError('glob pattern string required')
53447- }
53463+ assertValidPattern(pattern)
5344853464
5344953465 if (!options) options = {}
53466+
5345053467 pattern = pattern.trim()
5345153468
5345253469 // windows support: need to use /, not \
53453- if (path.sep !== '/') {
53470+ if (!options.allowWindowsEscape && path.sep !== '/') {
5345453471 pattern = pattern.split(path.sep).join('/')
5345553472 }
5345653473
@@ -53461,6 +53478,7 @@ function Minimatch (pattern, options) {
5346153478 this.negate = false
5346253479 this.comment = false
5346353480 this.empty = false
53481+ this.partial = !!options.partial
5346453482
5346553483 // make the set of regexps etc.
5346653484 this.make()
@@ -53470,9 +53488,6 @@ Minimatch.prototype.debug = function () {}
5347053488
5347153489Minimatch.prototype.make = make
5347253490function make () {
53473- // don't do it more than once.
53474- if (this._made) return
53475-
5347653491 var pattern = this.pattern
5347753492 var options = this.options
5347853493
@@ -53492,7 +53507,7 @@ function make () {
5349253507 // step 2: expand braces
5349353508 var set = this.globSet = this.braceExpand()
5349453509
53495- if (options.debug) this.debug = console.error
53510+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
5349653511
5349753512 this.debug(this.pattern, set)
5349853513
@@ -53572,19 +53587,29 @@ function braceExpand (pattern, options) {
5357253587 pattern = typeof pattern === 'undefined'
5357353588 ? this.pattern : pattern
5357453589
53575- if (typeof pattern === 'undefined') {
53576- throw new TypeError('undefined pattern')
53577- }
53590+ assertValidPattern(pattern)
5357853591
53579- if (options.nobrace ||
53580- !pattern.match(/\{.*\}/)) {
53592+ // Thanks to Yeting Li <https://github.com/yetingli> for
53593+ // improving this regexp to avoid a ReDOS vulnerability.
53594+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
5358153595 // shortcut. no need to expand.
5358253596 return [pattern]
5358353597 }
5358453598
5358553599 return expand(pattern)
5358653600}
5358753601
53602+ var MAX_PATTERN_LENGTH = 1024 * 64
53603+ var assertValidPattern = function (pattern) {
53604+ if (typeof pattern !== 'string') {
53605+ throw new TypeError('invalid pattern')
53606+ }
53607+
53608+ if (pattern.length > MAX_PATTERN_LENGTH) {
53609+ throw new TypeError('pattern is too long')
53610+ }
53611+ }
53612+
5358853613// parse a component of the expanded set.
5358953614// At this point, no pattern may contain "/" in it
5359053615// so we're going to return a 2d array, where each entry is the full
@@ -53599,14 +53624,17 @@ function braceExpand (pattern, options) {
5359953624Minimatch.prototype.parse = parse
5360053625var SUBPARSE = {}
5360153626function parse (pattern, isSub) {
53602- if (pattern.length > 1024 * 64) {
53603- throw new TypeError('pattern is too long')
53604- }
53627+ assertValidPattern(pattern)
5360553628
5360653629 var options = this.options
5360753630
5360853631 // shortcuts
53609- if (!options.noglobstar && pattern === '**') return GLOBSTAR
53632+ if (pattern === '**') {
53633+ if (!options.noglobstar)
53634+ return GLOBSTAR
53635+ else
53636+ pattern = '*'
53637+ }
5361053638 if (pattern === '') return ''
5361153639
5361253640 var re = ''
@@ -53662,10 +53690,12 @@ function parse (pattern, isSub) {
5366253690 }
5366353691
5366453692 switch (c) {
53665- case '/':
53693+ /* istanbul ignore next */
53694+ case '/': {
5366653695 // completely not allowed, even escaped.
5366753696 // Should already be path-split by now.
5366853697 return false
53698+ }
5366953699
5367053700 case '\\':
5367153701 clearStateChar()
@@ -53784,25 +53814,23 @@ function parse (pattern, isSub) {
5378453814
5378553815 // handle the case where we left a class open.
5378653816 // "[z-a]" is valid, equivalent to "\[z-a\]"
53787- if (inClass) {
53788- // split where the last [ was, make sure we don't have
53789- // an invalid re. if so, re-walk the contents of the
53790- // would-be class to re-translate any characters that
53791- // were passed through as-is
53792- // TODO: It would probably be faster to determine this
53793- // without a try/catch and a new RegExp, but it's tricky
53794- // to do safely. For now, this is safe and works.
53795- var cs = pattern.substring(classStart + 1, i)
53796- try {
53797- RegExp('[' + cs + ']')
53798- } catch (er) {
53799- // not a valid class!
53800- var sp = this.parse(cs, SUBPARSE)
53801- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
53802- hasMagic = hasMagic || sp[1]
53803- inClass = false
53804- continue
53805- }
53817+ // split where the last [ was, make sure we don't have
53818+ // an invalid re. if so, re-walk the contents of the
53819+ // would-be class to re-translate any characters that
53820+ // were passed through as-is
53821+ // TODO: It would probably be faster to determine this
53822+ // without a try/catch and a new RegExp, but it's tricky
53823+ // to do safely. For now, this is safe and works.
53824+ var cs = pattern.substring(classStart + 1, i)
53825+ try {
53826+ RegExp('[' + cs + ']')
53827+ } catch (er) {
53828+ // not a valid class!
53829+ var sp = this.parse(cs, SUBPARSE)
53830+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
53831+ hasMagic = hasMagic || sp[1]
53832+ inClass = false
53833+ continue
5380653834 }
5380753835
5380853836 // finish up the class.
@@ -53886,9 +53914,7 @@ function parse (pattern, isSub) {
5388653914 // something that could conceivably capture a dot
5388753915 var addPatternStart = false
5388853916 switch (re.charAt(0)) {
53889- case '.':
53890- case '[':
53891- case '(': addPatternStart = true
53917+ case '[': case '.': case '(': addPatternStart = true
5389253918 }
5389353919
5389453920 // Hack to work around lack of negative lookbehind in JS
@@ -53950,7 +53976,7 @@ function parse (pattern, isSub) {
5395053976 var flags = options.nocase ? 'i' : ''
5395153977 try {
5395253978 var regExp = new RegExp('^' + re + '$', flags)
53953- } catch (er) {
53979+ } catch (er) /* istanbul ignore next - should be impossible */ {
5395453980 // If it was an invalid regular expression, then it can't match
5395553981 // anything. This trick looks for a character after the end of
5395653982 // the string, which is of course impossible, except in multi-line
@@ -54008,7 +54034,7 @@ function makeRe () {
5400854034
5400954035 try {
5401054036 this.regexp = new RegExp(re, flags)
54011- } catch (ex) {
54037+ } catch (ex) /* istanbul ignore next - should be impossible */ {
5401254038 this.regexp = false
5401354039 }
5401454040 return this.regexp
@@ -54026,8 +54052,8 @@ minimatch.match = function (list, pattern, options) {
5402654052 return list
5402754053}
5402854054
54029- Minimatch.prototype.match = match
54030- function match (f, partial) {
54055+ Minimatch.prototype.match = function match (f, partial) {
54056+ if (typeof partial === 'undefined') partial = this.partial
5403154057 this.debug('match', f, this.pattern)
5403254058 // short-circuit in the case of busted things.
5403354059 // comments, etc.
@@ -54109,6 +54135,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
5410954135
5411054136 // should be impossible.
5411154137 // some invalid regexp stuff in the set.
54138+ /* istanbul ignore if */
5411254139 if (p === false) return false
5411354140
5411454141 if (p === GLOBSTAR) {
@@ -54182,6 +54209,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
5418254209 // no match was found.
5418354210 // However, in partial mode, we can't say this is necessarily over.
5418454211 // If there's more *pattern* left, then
54212+ /* istanbul ignore if */
5418554213 if (partial) {
5418654214 // ran out of file
5418754215 this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -54195,11 +54223,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
5419554223 // patterns with magic have been turned into regexps.
5419654224 var hit
5419754225 if (typeof p === 'string') {
54198- if (options.nocase) {
54199- hit = f.toLowerCase() === p.toLowerCase()
54200- } else {
54201- hit = f === p
54202- }
54226+ hit = f === p
5420354227 this.debug('string match', p, f, hit)
5420454228 } else {
5420554229 hit = f.match(p)
@@ -54230,16 +54254,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
5423054254 // this is ok if we're doing the match as part of
5423154255 // a glob fs traversal.
5423254256 return partial
54233- } else if (pi === pl) {
54257+ } else /* istanbul ignore else */ if (pi === pl) {
5423454258 // ran out of pattern, still have file left.
5423554259 // this is only acceptable if we're on the very last
5423654260 // empty segment of a file with a trailing slash.
5423754261 // a/* should match a/b/
54238- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
54239- return emptyFileEnd
54262+ return (fi === fl - 1) && (file[fi] === '')
5424054263 }
5424154264
5424254265 // should be unreachable.
54266+ /* istanbul ignore next */
5424354267 throw new Error('wtf?')
5424454268}
5424554269
0 commit comments