Skip to content

Commit 8457318

Browse files
build(deps): bump semver from 6.3.0 to 6.3.1 (#796)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent a422a81 commit 8457318

File tree

3 files changed

+154
-60
lines changed

3 files changed

+154
-60
lines changed

dist/post_run/index.js

Lines changed: 71 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56018,8 +56018,11 @@ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
5601856018
// Max safe segment length for coercion.
5601956019
var MAX_SAFE_COMPONENT_LENGTH = 16
5602056020

56021+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
56022+
5602156023
// The actual regexps go on exports.re
5602256024
var re = exports.re = []
56025+
var safeRe = exports.safeRe = []
5602356026
var src = exports.src = []
5602456027
var t = exports.tokens = {}
5602556028
var R = 0
@@ -56028,6 +56031,31 @@ function tok (n) {
5602856031
t[n] = R++
5602956032
}
5603056033

56034+
var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
56035+
56036+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
56037+
// used internally via the safeRe object since all inputs in this library get
56038+
// normalized first to trim and collapse all extra whitespace. The original
56039+
// regexes are exported for userland consumption and lower level usage. A
56040+
// future breaking change could export the safer regex only with a note that
56041+
// all input should have extra whitespace removed.
56042+
var safeRegexReplacements = [
56043+
['\\s', 1],
56044+
['\\d', MAX_LENGTH],
56045+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
56046+
]
56047+
56048+
function makeSafeRe (value) {
56049+
for (var i = 0; i < safeRegexReplacements.length; i++) {
56050+
var token = safeRegexReplacements[i][0]
56051+
var max = safeRegexReplacements[i][1]
56052+
value = value
56053+
.split(token + '*').join(token + '{0,' + max + '}')
56054+
.split(token + '+').join(token + '{1,' + max + '}')
56055+
}
56056+
return value
56057+
}
56058+
5603156059
// The following Regular Expressions can be used for tokenizing,
5603256060
// validating, and parsing SemVer version strings.
5603356061

@@ -56037,14 +56065,14 @@ function tok (n) {
5603756065
tok('NUMERICIDENTIFIER')
5603856066
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
5603956067
tok('NUMERICIDENTIFIERLOOSE')
56040-
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'
56068+
src[t.NUMERICIDENTIFIERLOOSE] = '\\d+'
5604156069

5604256070
// ## Non-numeric Identifier
5604356071
// Zero or more digits, followed by a letter or hyphen, and then zero or
5604456072
// more letters, digits, or hyphens.
5604556073

5604656074
tok('NONNUMERICIDENTIFIER')
56047-
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
56075+
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*'
5604856076

5604956077
// ## Main Version
5605056078
// Three dot-separated numeric identifiers.
@@ -56086,7 +56114,7 @@ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
5608656114
// Any combination of digits, letters, or hyphens.
5608756115

5608856116
tok('BUILDIDENTIFIER')
56089-
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
56117+
src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + '+'
5609056118

5609156119
// ## Build Metadata
5609256120
// Plus sign, followed by one or more period-separated build metadata
@@ -56166,6 +56194,7 @@ src[t.COERCE] = '(^|[^\\d])' +
5616656194
'(?:$|[^\\d])'
5616756195
tok('COERCERTL')
5616856196
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
56197+
safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), 'g')
5616956198

5617056199
// Tilde ranges.
5617156200
// Meaning is "reasonably at or greater than"
@@ -56175,6 +56204,7 @@ src[t.LONETILDE] = '(?:~>?)'
5617556204
tok('TILDETRIM')
5617656205
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
5617756206
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
56207+
safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), 'g')
5617856208
var tildeTrimReplace = '$1~'
5617956209

5618056210
tok('TILDE')
@@ -56190,6 +56220,7 @@ src[t.LONECARET] = '(?:\\^)'
5619056220
tok('CARETTRIM')
5619156221
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
5619256222
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
56223+
safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), 'g')
5619356224
var caretTrimReplace = '$1^'
5619456225

5619556226
tok('CARET')
@@ -56211,6 +56242,7 @@ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
5621156242

5621256243
// this one has to use the /g flag
5621356244
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
56245+
safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), 'g')
5621456246
var comparatorTrimReplace = '$1$2$3'
5621556247

5621656248
// Something like `1.2.3 - 1.2.4`
@@ -56239,6 +56271,14 @@ for (var i = 0; i < R; i++) {
5623956271
debug(i, src[i])
5624056272
if (!re[i]) {
5624156273
re[i] = new RegExp(src[i])
56274+
56275+
// Replace all greedy whitespace to prevent regex dos issues. These regex are
56276+
// used internally via the safeRe object since all inputs in this library get
56277+
// normalized first to trim and collapse all extra whitespace. The original
56278+
// regexes are exported for userland consumption and lower level usage. A
56279+
// future breaking change could export the safer regex only with a note that
56280+
// all input should have extra whitespace removed.
56281+
safeRe[i] = new RegExp(makeSafeRe(src[i]))
5624256282
}
5624356283
}
5624456284

@@ -56263,7 +56303,7 @@ function parse (version, options) {
5626356303
return null
5626456304
}
5626556305

56266-
var r = options.loose ? re[t.LOOSE] : re[t.FULL]
56306+
var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]
5626756307
if (!r.test(version)) {
5626856308
return null
5626956309
}
@@ -56318,7 +56358,7 @@ function SemVer (version, options) {
5631856358
this.options = options
5631956359
this.loose = !!options.loose
5632056360

56321-
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
56361+
var m = version.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL])
5632256362

5632356363
if (!m) {
5632456364
throw new TypeError('Invalid Version: ' + version)
@@ -56763,6 +56803,7 @@ function Comparator (comp, options) {
5676356803
return new Comparator(comp, options)
5676456804
}
5676556805

56806+
comp = comp.trim().split(/\s+/).join(' ')
5676656807
debug('comparator', comp, options)
5676756808
this.options = options
5676856809
this.loose = !!options.loose
@@ -56779,7 +56820,7 @@ function Comparator (comp, options) {
5677956820

5678056821
var ANY = {}
5678156822
Comparator.prototype.parse = function (comp) {
56782-
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
56823+
var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
5678356824
var m = comp.match(r)
5678456825

5678556826
if (!m) {
@@ -56903,17 +56944,24 @@ function Range (range, options) {
5690356944
this.loose = !!options.loose
5690456945
this.includePrerelease = !!options.includePrerelease
5690556946

56906-
// First, split based on boolean or ||
56947+
// First reduce all whitespace as much as possible so we do not have to rely
56948+
// on potentially slow regexes like \s*. This is then stored and used for
56949+
// future error messages as well.
5690756950
this.raw = range
56908-
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
56951+
.trim()
56952+
.split(/\s+/)
56953+
.join(' ')
56954+
56955+
// First, split based on boolean or ||
56956+
this.set = this.raw.split('||').map(function (range) {
5690956957
return this.parseRange(range.trim())
5691056958
}, this).filter(function (c) {
5691156959
// throw out any that are not relevant for whatever reason
5691256960
return c.length
5691356961
})
5691456962

5691556963
if (!this.set.length) {
56916-
throw new TypeError('Invalid SemVer Range: ' + range)
56964+
throw new TypeError('Invalid SemVer Range: ' + this.raw)
5691756965
}
5691856966

5691956967
this.format()
@@ -56932,28 +56980,27 @@ Range.prototype.toString = function () {
5693256980

5693356981
Range.prototype.parseRange = function (range) {
5693456982
var loose = this.options.loose
56935-
range = range.trim()
5693656983
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
56937-
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
56984+
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE]
5693856985
range = range.replace(hr, hyphenReplace)
5693956986
debug('hyphen replace', range)
5694056987
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
56941-
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
56942-
debug('comparator trim', range, re[t.COMPARATORTRIM])
56988+
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace)
56989+
debug('comparator trim', range, safeRe[t.COMPARATORTRIM])
5694356990

5694456991
// `~ 1.2.3` => `~1.2.3`
56945-
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
56992+
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace)
5694656993

5694756994
// `^ 1.2.3` => `^1.2.3`
56948-
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
56995+
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace)
5694956996

5695056997
// normalize spaces
5695156998
range = range.split(/\s+/).join(' ')
5695256999

5695357000
// At this point, the range is completely trimmed and
5695457001
// ready to be split into comparators.
5695557002

56956-
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
57003+
var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
5695757004
var set = range.split(' ').map(function (comp) {
5695857005
return parseComparator(comp, this.options)
5695957006
}, this).join(' ').split(/\s+/)
@@ -57053,7 +57100,7 @@ function replaceTildes (comp, options) {
5705357100
}
5705457101

5705557102
function replaceTilde (comp, options) {
57056-
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
57103+
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE]
5705757104
return comp.replace(r, function (_, M, m, p, pr) {
5705857105
debug('tilde', comp, _, M, m, p, pr)
5705957106
var ret
@@ -57094,7 +57141,7 @@ function replaceCarets (comp, options) {
5709457141

5709557142
function replaceCaret (comp, options) {
5709657143
debug('caret', comp, options)
57097-
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
57144+
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET]
5709857145
return comp.replace(r, function (_, M, m, p, pr) {
5709957146
debug('caret', comp, _, M, m, p, pr)
5710057147
var ret
@@ -57153,7 +57200,7 @@ function replaceXRanges (comp, options) {
5715357200

5715457201
function replaceXRange (comp, options) {
5715557202
comp = comp.trim()
57156-
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
57203+
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE]
5715757204
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
5715857205
debug('xRange', comp, ret, gtlt, M, m, p, pr)
5715957206
var xM = isX(M)
@@ -57228,7 +57275,7 @@ function replaceXRange (comp, options) {
5722857275
function replaceStars (comp, options) {
5722957276
debug('replaceStars', comp, options)
5723057277
// Looseness is ignored here. star is always as loose as it gets!
57231-
return comp.trim().replace(re[t.STAR], '')
57278+
return comp.trim().replace(safeRe[t.STAR], '')
5723257279
}
5723357280

5723457281
// This function is passed to string.replace(re[t.HYPHENRANGE])
@@ -57554,7 +57601,7 @@ function coerce (version, options) {
5755457601

5755557602
var match = null
5755657603
if (!options.rtl) {
57557-
match = version.match(re[t.COERCE])
57604+
match = version.match(safeRe[t.COERCE])
5755857605
} else {
5755957606
// Find the right-most coercible string that does not share
5756057607
// a terminus with a more left-ward coercible string.
@@ -57565,17 +57612,17 @@ function coerce (version, options) {
5756557612
// Stop when we get a match that ends at the string end, since no
5756657613
// coercible string can be more right-ward without the same terminus.
5756757614
var next
57568-
while ((next = re[t.COERCERTL].exec(version)) &&
57615+
while ((next = safeRe[t.COERCERTL].exec(version)) &&
5756957616
(!match || match.index + match[0].length !== version.length)
5757057617
) {
5757157618
if (!match ||
5757257619
next.index + next[0].length !== match.index + match[0].length) {
5757357620
match = next
5757457621
}
57575-
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
57622+
safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
5757657623
}
5757757624
// leave it in a clean state
57578-
re[t.COERCERTL].lastIndex = -1
57625+
safeRe[t.COERCERTL].lastIndex = -1
5757957626
}
5758057627

5758157628
if (match === null) {

0 commit comments

Comments
 (0)