@@ -1877,7 +1877,20 @@ const serializers = {
1877
1877
)}`;
1878
1878
},
1879
1879
IssuesEvent: (item) => {
1880
- const emoji = item.payload.action === "opened" ? "❗" : "🔒";
1880
+ let emoji = "";
1881
+
1882
+ switch (item.payload.action) {
1883
+ case "opened":
1884
+ emoji = "❗";
1885
+ break;
1886
+ case "reopened":
1887
+ emoji = "🔓";
1888
+ break;
1889
+ case "closed":
1890
+ emoji = "🔒";
1891
+ break;
1892
+ }
1893
+
1881
1894
return `${emoji} ${capitalize(item.payload.action)} issue ${toUrlFormat(
1882
1895
item
1883
1896
)} in ${toUrlFormat(item.repo.name)}`;
@@ -4441,11 +4454,39 @@ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
4441
4454
// Max safe segment length for coercion.
4442
4455
var MAX_SAFE_COMPONENT_LENGTH = 16
4443
4456
4457
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
4458
+
4444
4459
// The actual regexps go on exports.re
4445
4460
var re = exports.re = []
4461
+ var safeRe = exports.safeRe = []
4446
4462
var src = exports.src = []
4447
4463
var R = 0
4448
4464
4465
+ var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
4466
+
4467
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
4468
+ // used internally via the safeRe object since all inputs in this library get
4469
+ // normalized first to trim and collapse all extra whitespace. The original
4470
+ // regexes are exported for userland consumption and lower level usage. A
4471
+ // future breaking change could export the safer regex only with a note that
4472
+ // all input should have extra whitespace removed.
4473
+ var safeRegexReplacements = [
4474
+ ['\\s', 1],
4475
+ ['\\d', MAX_LENGTH],
4476
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
4477
+ ]
4478
+
4479
+ function makeSafeRe (value) {
4480
+ for (var i = 0; i < safeRegexReplacements.length; i++) {
4481
+ var token = safeRegexReplacements[i][0]
4482
+ var max = safeRegexReplacements[i][1]
4483
+ value = value
4484
+ .split(token + '*').join(token + '{0,' + max + '}')
4485
+ .split(token + '+').join(token + '{1,' + max + '}')
4486
+ }
4487
+ return value
4488
+ }
4489
+
4449
4490
// The following Regular Expressions can be used for tokenizing,
4450
4491
// validating, and parsing SemVer version strings.
4451
4492
@@ -4455,14 +4496,14 @@ var R = 0
4455
4496
var NUMERICIDENTIFIER = R++
4456
4497
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
4457
4498
var NUMERICIDENTIFIERLOOSE = R++
4458
- src[NUMERICIDENTIFIERLOOSE] = '[0-9] +'
4499
+ src[NUMERICIDENTIFIERLOOSE] = '\\d +'
4459
4500
4460
4501
// ## Non-numeric Identifier
4461
4502
// Zero or more digits, followed by a letter or hyphen, and then zero or
4462
4503
// more letters, digits, or hyphens.
4463
4504
4464
4505
var NONNUMERICIDENTIFIER = R++
4465
- src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-] *'
4506
+ src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + ' *'
4466
4507
4467
4508
// ## Main Version
4468
4509
// Three dot-separated numeric identifiers.
@@ -4504,7 +4545,7 @@ src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
4504
4545
// Any combination of digits, letters, or hyphens.
4505
4546
4506
4547
var BUILDIDENTIFIER = R++
4507
- src[BUILDIDENTIFIER] = '[0-9A-Za-z-] +'
4548
+ src[BUILDIDENTIFIER] = LETTERDASHNUMBER + ' +'
4508
4549
4509
4550
// ## Build Metadata
4510
4551
// Plus sign, followed by one or more period-separated build metadata
@@ -4589,6 +4630,7 @@ src[LONETILDE] = '(?:~>?)'
4589
4630
var TILDETRIM = R++
4590
4631
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
4591
4632
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
4633
+ safeRe[TILDETRIM] = new RegExp(makeSafeRe(src[TILDETRIM]), 'g')
4592
4634
var tildeTrimReplace = '$1~'
4593
4635
4594
4636
var TILDE = R++
@@ -4604,6 +4646,7 @@ src[LONECARET] = '(?:\\^)'
4604
4646
var CARETTRIM = R++
4605
4647
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
4606
4648
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
4649
+ safeRe[CARETTRIM] = new RegExp(makeSafeRe(src[CARETTRIM]), 'g')
4607
4650
var caretTrimReplace = '$1^'
4608
4651
4609
4652
var CARET = R++
@@ -4625,6 +4668,7 @@ src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
4625
4668
4626
4669
// this one has to use the /g flag
4627
4670
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
4671
+ safeRe[COMPARATORTRIM] = new RegExp(makeSafeRe(src[COMPARATORTRIM]), 'g')
4628
4672
var comparatorTrimReplace = '$1$2$3'
4629
4673
4630
4674
// Something like `1.2.3 - 1.2.4`
@@ -4653,6 +4697,14 @@ for (var i = 0; i < R; i++) {
4653
4697
debug(i, src[i])
4654
4698
if (!re[i]) {
4655
4699
re[i] = new RegExp(src[i])
4700
+
4701
+ // Replace all greedy whitespace to prevent regex dos issues. These regex are
4702
+ // used internally via the safeRe object since all inputs in this library get
4703
+ // normalized first to trim and collapse all extra whitespace. The original
4704
+ // regexes are exported for userland consumption and lower level usage. A
4705
+ // future breaking change could export the safer regex only with a note that
4706
+ // all input should have extra whitespace removed.
4707
+ safeRe[i] = new RegExp(makeSafeRe(src[i]))
4656
4708
}
4657
4709
}
4658
4710
@@ -4677,7 +4729,7 @@ function parse (version, options) {
4677
4729
return null
4678
4730
}
4679
4731
4680
- var r = options.loose ? re [LOOSE] : re [FULL]
4732
+ var r = options.loose ? safeRe [LOOSE] : safeRe [FULL]
4681
4733
if (!r.test(version)) {
4682
4734
return null
4683
4735
}
@@ -4732,7 +4784,7 @@ function SemVer (version, options) {
4732
4784
this.options = options
4733
4785
this.loose = !!options.loose
4734
4786
4735
- var m = version.trim().match(options.loose ? re [LOOSE] : re [FULL])
4787
+ var m = version.trim().match(options.loose ? safeRe [LOOSE] : safeRe [FULL])
4736
4788
4737
4789
if (!m) {
4738
4790
throw new TypeError('Invalid Version: ' + version)
@@ -5146,6 +5198,7 @@ function Comparator (comp, options) {
5146
5198
return new Comparator(comp, options)
5147
5199
}
5148
5200
5201
+ comp = comp.trim().split(/\s+/).join(' ')
5149
5202
debug('comparator', comp, options)
5150
5203
this.options = options
5151
5204
this.loose = !!options.loose
@@ -5162,7 +5215,7 @@ function Comparator (comp, options) {
5162
5215
5163
5216
var ANY = {}
5164
5217
Comparator.prototype.parse = function (comp) {
5165
- var r = this.options.loose ? re [COMPARATORLOOSE] : re [COMPARATOR]
5218
+ var r = this.options.loose ? safeRe [COMPARATORLOOSE] : safeRe [COMPARATOR]
5166
5219
var m = comp.match(r)
5167
5220
5168
5221
if (!m) {
@@ -5276,17 +5329,24 @@ function Range (range, options) {
5276
5329
this.loose = !!options.loose
5277
5330
this.includePrerelease = !!options.includePrerelease
5278
5331
5279
- // First, split based on boolean or ||
5332
+ // First reduce all whitespace as much as possible so we do not have to rely
5333
+ // on potentially slow regexes like \s*. This is then stored and used for
5334
+ // future error messages as well.
5280
5335
this.raw = range
5281
- this.set = range.split(/\s*\|\|\s*/).map(function (range) {
5336
+ .trim()
5337
+ .split(/\s+/)
5338
+ .join(' ')
5339
+
5340
+ // First, split based on boolean or ||
5341
+ this.set = this.raw.split('||').map(function (range) {
5282
5342
return this.parseRange(range.trim())
5283
5343
}, this).filter(function (c) {
5284
5344
// throw out any that are not relevant for whatever reason
5285
5345
return c.length
5286
5346
})
5287
5347
5288
5348
if (!this.set.length) {
5289
- throw new TypeError('Invalid SemVer Range: ' + range )
5349
+ throw new TypeError('Invalid SemVer Range: ' + this.raw )
5290
5350
}
5291
5351
5292
5352
this.format()
@@ -5305,28 +5365,23 @@ Range.prototype.toString = function () {
5305
5365
5306
5366
Range.prototype.parseRange = function (range) {
5307
5367
var loose = this.options.loose
5308
- range = range.trim()
5309
5368
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
5310
- var hr = loose ? re [HYPHENRANGELOOSE] : re [HYPHENRANGE]
5369
+ var hr = loose ? safeRe [HYPHENRANGELOOSE] : safeRe [HYPHENRANGE]
5311
5370
range = range.replace(hr, hyphenReplace)
5312
5371
debug('hyphen replace', range)
5313
5372
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
5314
- range = range.replace(re [COMPARATORTRIM], comparatorTrimReplace)
5315
- debug('comparator trim', range, re [COMPARATORTRIM])
5373
+ range = range.replace(safeRe [COMPARATORTRIM], comparatorTrimReplace)
5374
+ debug('comparator trim', range, safeRe [COMPARATORTRIM])
5316
5375
5317
5376
// `~ 1.2.3` => `~1.2.3`
5318
- range = range.replace(re [TILDETRIM], tildeTrimReplace)
5377
+ range = range.replace(safeRe [TILDETRIM], tildeTrimReplace)
5319
5378
5320
5379
// `^ 1.2.3` => `^1.2.3`
5321
- range = range.replace(re[CARETTRIM], caretTrimReplace)
5322
-
5323
- // normalize spaces
5324
- range = range.split(/\s+/).join(' ')
5380
+ range = range.replace(safeRe[CARETTRIM], caretTrimReplace)
5325
5381
5326
5382
// At this point, the range is completely trimmed and
5327
5383
// ready to be split into comparators.
5328
-
5329
- var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
5384
+ var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR]
5330
5385
var set = range.split(' ').map(function (comp) {
5331
5386
return parseComparator(comp, this.options)
5332
5387
}, this).join(' ').split(/\s+/)
@@ -5402,7 +5457,7 @@ function replaceTildes (comp, options) {
5402
5457
}
5403
5458
5404
5459
function replaceTilde (comp, options) {
5405
- var r = options.loose ? re [TILDELOOSE] : re [TILDE]
5460
+ var r = options.loose ? safeRe [TILDELOOSE] : safeRe [TILDE]
5406
5461
return comp.replace(r, function (_, M, m, p, pr) {
5407
5462
debug('tilde', comp, _, M, m, p, pr)
5408
5463
var ret
@@ -5443,7 +5498,7 @@ function replaceCarets (comp, options) {
5443
5498
5444
5499
function replaceCaret (comp, options) {
5445
5500
debug('caret', comp, options)
5446
- var r = options.loose ? re [CARETLOOSE] : re [CARET]
5501
+ var r = options.loose ? safeRe [CARETLOOSE] : safeRe [CARET]
5447
5502
return comp.replace(r, function (_, M, m, p, pr) {
5448
5503
debug('caret', comp, _, M, m, p, pr)
5449
5504
var ret
@@ -5502,7 +5557,7 @@ function replaceXRanges (comp, options) {
5502
5557
5503
5558
function replaceXRange (comp, options) {
5504
5559
comp = comp.trim()
5505
- var r = options.loose ? re [XRANGELOOSE] : re [XRANGE]
5560
+ var r = options.loose ? safeRe [XRANGELOOSE] : safeRe [XRANGE]
5506
5561
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
5507
5562
debug('xRange', comp, ret, gtlt, M, m, p, pr)
5508
5563
var xM = isX(M)
@@ -5572,10 +5627,10 @@ function replaceXRange (comp, options) {
5572
5627
function replaceStars (comp, options) {
5573
5628
debug('replaceStars', comp, options)
5574
5629
// Looseness is ignored here. star is always as loose as it gets!
5575
- return comp.trim().replace(re [STAR], '')
5630
+ return comp.trim().replace(safeRe [STAR], '')
5576
5631
}
5577
5632
5578
- // This function is passed to string.replace(re [HYPHENRANGE])
5633
+ // This function is passed to string.replace(safeRe [HYPHENRANGE])
5579
5634
// M, m, patch, prerelease, build
5580
5635
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
5581
5636
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
@@ -5886,7 +5941,7 @@ function coerce (version) {
5886
5941
return null
5887
5942
}
5888
5943
5889
- var match = version.match(re [COERCE])
5944
+ var match = version.match(safeRe [COERCE])
5890
5945
5891
5946
if (match == null) {
5892
5947
return null
0 commit comments