@@ -45312,10 +45312,10 @@ function populateMaps (extensions, types) {
4531245312module.exports = minimatch
4531345313minimatch.Minimatch = Minimatch
4531445314
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
4531945319
4532045320var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
4532145321var expand = __nccwpck_require__(3717)
@@ -45367,43 +45367,64 @@ function filter (pattern, options) {
4536745367}
4536845368
4536945369function ext (a, b) {
45370- a = a || {}
4537145370 b = b || {}
4537245371 var t = {}
45373- Object.keys(b).forEach(function (k) {
45374- t[k] = b[k]
45375- })
4537645372 Object.keys(a).forEach(function (k) {
4537745373 t[k] = a[k]
4537845374 })
45375+ Object.keys(b).forEach(function (k) {
45376+ t[k] = b[k]
45377+ })
4537945378 return t
4538045379}
4538145380
4538245381minimatch.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+ }
4538445385
4538545386 var orig = minimatch
4538645387
4538745388 var m = function minimatch (p, pattern, options) {
45388- return orig.minimatch (p, pattern, ext(def, options))
45389+ return orig(p, pattern, ext(def, options))
4538945390 }
4539045391
4539145392 m.Minimatch = function Minimatch (pattern, options) {
4539245393 return new orig.Minimatch(pattern, ext(def, options))
4539345394 }
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+ }
4539445418
4539545419 return m
4539645420}
4539745421
4539845422Minimatch.defaults = function (def) {
45399- if (!def || !Object.keys(def).length) return Minimatch
4540045423 return minimatch.defaults(def).Minimatch
4540145424}
4540245425
4540345426function minimatch (p, pattern, options) {
45404- if (typeof pattern !== 'string') {
45405- throw new TypeError('glob pattern string required')
45406- }
45427+ assertValidPattern(pattern)
4540745428
4540845429 if (!options) options = {}
4540945430
@@ -45412,9 +45433,6 @@ function minimatch (p, pattern, options) {
4541245433 return false
4541345434 }
4541445435
45415- // "" only matches ""
45416- if (pattern.trim() === '') return p === ''
45417-
4541845436 return new Minimatch(pattern, options).match(p)
4541945437}
4542045438
@@ -45423,15 +45441,14 @@ function Minimatch (pattern, options) {
4542345441 return new Minimatch(pattern, options)
4542445442 }
4542545443
45426- if (typeof pattern !== 'string') {
45427- throw new TypeError('glob pattern string required')
45428- }
45444+ assertValidPattern(pattern)
4542945445
4543045446 if (!options) options = {}
45447+
4543145448 pattern = pattern.trim()
4543245449
4543345450 // windows support: need to use /, not \
45434- if (path.sep !== '/') {
45451+ if (!options.allowWindowsEscape && path.sep !== '/') {
4543545452 pattern = pattern.split(path.sep).join('/')
4543645453 }
4543745454
@@ -45442,6 +45459,7 @@ function Minimatch (pattern, options) {
4544245459 this.negate = false
4544345460 this.comment = false
4544445461 this.empty = false
45462+ this.partial = !!options.partial
4544545463
4544645464 // make the set of regexps etc.
4544745465 this.make()
@@ -45451,9 +45469,6 @@ Minimatch.prototype.debug = function () {}
4545145469
4545245470Minimatch.prototype.make = make
4545345471function make () {
45454- // don't do it more than once.
45455- if (this._made) return
45456-
4545745472 var pattern = this.pattern
4545845473 var options = this.options
4545945474
@@ -45473,7 +45488,7 @@ function make () {
4547345488 // step 2: expand braces
4547445489 var set = this.globSet = this.braceExpand()
4547545490
45476- if (options.debug) this.debug = console.error
45491+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
4547745492
4547845493 this.debug(this.pattern, set)
4547945494
@@ -45553,19 +45568,29 @@ function braceExpand (pattern, options) {
4555345568 pattern = typeof pattern === 'undefined'
4555445569 ? this.pattern : pattern
4555545570
45556- if (typeof pattern === 'undefined') {
45557- throw new TypeError('undefined pattern')
45558- }
45571+ assertValidPattern(pattern)
4555945572
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)) {
4556245576 // shortcut. no need to expand.
4556345577 return [pattern]
4556445578 }
4556545579
4556645580 return expand(pattern)
4556745581}
4556845582
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+
4556945594// parse a component of the expanded set.
4557045595// At this point, no pattern may contain "/" in it
4557145596// so we're going to return a 2d array, where each entry is the full
@@ -45580,14 +45605,17 @@ function braceExpand (pattern, options) {
4558045605Minimatch.prototype.parse = parse
4558145606var SUBPARSE = {}
4558245607function parse (pattern, isSub) {
45583- if (pattern.length > 1024 * 64) {
45584- throw new TypeError('pattern is too long')
45585- }
45608+ assertValidPattern(pattern)
4558645609
4558745610 var options = this.options
4558845611
4558945612 // shortcuts
45590- if (!options.noglobstar && pattern === '**') return GLOBSTAR
45613+ if (pattern === '**') {
45614+ if (!options.noglobstar)
45615+ return GLOBSTAR
45616+ else
45617+ pattern = '*'
45618+ }
4559145619 if (pattern === '') return ''
4559245620
4559345621 var re = ''
@@ -45643,10 +45671,12 @@ function parse (pattern, isSub) {
4564345671 }
4564445672
4564545673 switch (c) {
45646- case '/':
45674+ /* istanbul ignore next */
45675+ case '/': {
4564745676 // completely not allowed, even escaped.
4564845677 // Should already be path-split by now.
4564945678 return false
45679+ }
4565045680
4565145681 case '\\':
4565245682 clearStateChar()
@@ -45765,25 +45795,23 @@ function parse (pattern, isSub) {
4576545795
4576645796 // handle the case where we left a class open.
4576745797 // "[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
4578745815 }
4578845816
4578945817 // finish up the class.
@@ -45867,9 +45895,7 @@ function parse (pattern, isSub) {
4586745895 // something that could conceivably capture a dot
4586845896 var addPatternStart = false
4586945897 switch (re.charAt(0)) {
45870- case '.':
45871- case '[':
45872- case '(': addPatternStart = true
45898+ case '[': case '.': case '(': addPatternStart = true
4587345899 }
4587445900
4587545901 // Hack to work around lack of negative lookbehind in JS
@@ -45931,7 +45957,7 @@ function parse (pattern, isSub) {
4593145957 var flags = options.nocase ? 'i' : ''
4593245958 try {
4593345959 var regExp = new RegExp('^' + re + '$', flags)
45934- } catch (er) {
45960+ } catch (er) /* istanbul ignore next - should be impossible */ {
4593545961 // If it was an invalid regular expression, then it can't match
4593645962 // anything. This trick looks for a character after the end of
4593745963 // the string, which is of course impossible, except in multi-line
@@ -45989,7 +46015,7 @@ function makeRe () {
4598946015
4599046016 try {
4599146017 this.regexp = new RegExp(re, flags)
45992- } catch (ex) {
46018+ } catch (ex) /* istanbul ignore next - should be impossible */ {
4599346019 this.regexp = false
4599446020 }
4599546021 return this.regexp
@@ -46007,8 +46033,8 @@ minimatch.match = function (list, pattern, options) {
4600746033 return list
4600846034}
4600946035
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
4601246038 this.debug('match', f, this.pattern)
4601346039 // short-circuit in the case of busted things.
4601446040 // comments, etc.
@@ -46090,6 +46116,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
4609046116
4609146117 // should be impossible.
4609246118 // some invalid regexp stuff in the set.
46119+ /* istanbul ignore if */
4609346120 if (p === false) return false
4609446121
4609546122 if (p === GLOBSTAR) {
@@ -46163,6 +46190,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
4616346190 // no match was found.
4616446191 // However, in partial mode, we can't say this is necessarily over.
4616546192 // If there's more *pattern* left, then
46193+ /* istanbul ignore if */
4616646194 if (partial) {
4616746195 // ran out of file
4616846196 this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -46176,11 +46204,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
4617646204 // patterns with magic have been turned into regexps.
4617746205 var hit
4617846206 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
4618446208 this.debug('string match', p, f, hit)
4618546209 } else {
4618646210 hit = f.match(p)
@@ -46211,16 +46235,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
4621146235 // this is ok if we're doing the match as part of
4621246236 // a glob fs traversal.
4621346237 return partial
46214- } else if (pi === pl) {
46238+ } else /* istanbul ignore else */ if (pi === pl) {
4621546239 // ran out of pattern, still have file left.
4621646240 // this is only acceptable if we're on the very last
4621746241 // empty segment of a file with a trailing slash.
4621846242 // a/* should match a/b/
46219- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
46220- return emptyFileEnd
46243+ return (fi === fl - 1) && (file[fi] === '')
4622146244 }
4622246245
4622346246 // should be unreachable.
46247+ /* istanbul ignore next */
4622446248 throw new Error('wtf?')
4622546249}
4622646250
0 commit comments