| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a00ea43 commit e8111ce
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,10 +93,3 @@ jobs: | |||
| 93 | 93 | python-version: '<3.11' | |
| 94 | 94 | - name: Verify <3.11 | |
| 95 | 95 | run: python __tests__/verify-python.py 3.10 | |
| 96 | - | ||
| 97 | - - name: Run with setup-python >3.8 | ||
| 98 | - uses: ./ | ||
| 99 | - with: | ||
| 100 | - python-version: '>3.8' | ||
| 101 | - - name: Verify >3.8 | ||
| 102 | - run: python __tests__/verify-python.py 3.11 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3300,8 +3300,11 @@ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || | |||
| 3300 | 3300 | // Max safe segment length for coercion. | |
| 3301 | 3301 | var MAX_SAFE_COMPONENT_LENGTH = 16 | |
| 3302 | 3302 | ||
| 3303 | + var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6 | ||
| 3304 | + | ||
| 3303 | 3305 | // The actual regexps go on exports.re | |
| 3304 | 3306 | var re = exports.re = [] | |
| 3307 | + var safeRe = exports.safeRe = [] | ||
| 3305 | 3308 | var src = exports.src = [] | |
| 3306 | 3309 | var t = exports.tokens = {} | |
| 3307 | 3310 | var R = 0 | |
@@ -3310,6 +3313,31 @@ function tok (n) { | |||
| 3310 | 3313 | t[n] = R++ | |
| 3311 | 3314 | } | |
| 3312 | 3315 | ||
| 3316 | + var LETTERDASHNUMBER = '[a-zA-Z0-9-]' | ||
| 3317 | + | ||
| 3318 | + // Replace some greedy regex tokens to prevent regex dos issues. These regex are | ||
| 3319 | + // used internally via the safeRe object since all inputs in this library get | ||
| 3320 | + // normalized first to trim and collapse all extra whitespace. The original | ||
| 3321 | + // regexes are exported for userland consumption and lower level usage. A | ||
| 3322 | + // future breaking change could export the safer regex only with a note that | ||
| 3323 | + // all input should have extra whitespace removed. | ||
| 3324 | + var safeRegexReplacements = [ | ||
| 3325 | + ['\\s', 1], | ||
| 3326 | + ['\\d', MAX_LENGTH], | ||
| 3327 | + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], | ||
| 3328 | + ] | ||
| 3329 | + | ||
| 3330 | + function makeSafeRe (value) { | ||
| 3331 | + for (var i = 0; i < safeRegexReplacements.length; i++) { | ||
| 3332 | + var token = safeRegexReplacements[i][0] | ||
| 3333 | + var max = safeRegexReplacements[i][1] | ||
| 3334 | + value = value | ||
| 3335 | + .split(token + '*').join(token + '{0,' + max + '}') | ||
| 3336 | + .split(token + '+').join(token + '{1,' + max + '}') | ||
| 3337 | + } | ||
| 3338 | + return value | ||
| 3339 | + } | ||
| 3340 | + | ||
| 3313 | 3341 | // The following Regular Expressions can be used for tokenizing, | |
| 3314 | 3342 | // validating, and parsing SemVer version strings. | |
| 3315 | 3343 | ||
@@ -3319,14 +3347,14 @@ function tok (n) { | |||
| 3319 | 3347 | tok('NUMERICIDENTIFIER') | |
| 3320 | 3348 | src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' | |
| 3321 | 3349 | tok('NUMERICIDENTIFIERLOOSE') | |
| 3322 | - src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' | ||
| 3350 | + src[t.NUMERICIDENTIFIERLOOSE] = '\\d+' | ||
| 3323 | 3351 | ||
| 3324 | 3352 | // ## Non-numeric Identifier | |
| 3325 | 3353 | // Zero or more digits, followed by a letter or hyphen, and then zero or | |
| 3326 | 3354 | // more letters, digits, or hyphens. | |
| 3327 | 3355 | ||
| 3328 | 3356 | tok('NONNUMERICIDENTIFIER') | |
| 3329 | - src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' | ||
| 3357 | + src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*' | ||
| 3330 | 3358 | ||
| 3331 | 3359 | // ## Main Version | |
| 3332 | 3360 | // Three dot-separated numeric identifiers. | |
@@ -3368,7 +3396,7 @@ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + | |||
| 3368 | 3396 | // Any combination of digits, letters, or hyphens. | |
| 3369 | 3397 | ||
| 3370 | 3398 | tok('BUILDIDENTIFIER') | |
| 3371 | - src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' | ||
| 3399 | + src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + '+' | ||
| 3372 | 3400 | ||
| 3373 | 3401 | // ## Build Metadata | |
| 3374 | 3402 | // Plus sign, followed by one or more period-separated build metadata | |
@@ -3448,6 +3476,7 @@ src[t.COERCE] = '(^|[^\\d])' + | |||
| 3448 | 3476 | '(?:$|[^\\d])' | |
| 3449 | 3477 | tok('COERCERTL') | |
| 3450 | 3478 | re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') | |
| 3479 | + safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), 'g') | ||
| 3451 | 3480 | ||
| 3452 | 3481 | // Tilde ranges. | |
| 3453 | 3482 | // Meaning is "reasonably at or greater than" | |
@@ -3457,6 +3486,7 @@ src[t.LONETILDE] = '(?:~>?)' | |||
| 3457 | 3486 | tok('TILDETRIM') | |
| 3458 | 3487 | src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' | |
| 3459 | 3488 | re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') | |
| 3489 | + safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), 'g') | ||
| 3460 | 3490 | var tildeTrimReplace = '$1~' | |
| 3461 | 3491 | ||
| 3462 | 3492 | tok('TILDE') | |
@@ -3472,6 +3502,7 @@ src[t.LONECARET] = '(?:\\^)' | |||
| 3472 | 3502 | tok('CARETTRIM') | |
| 3473 | 3503 | src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' | |
| 3474 | 3504 | re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') | |
| 3505 | + safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), 'g') | ||
| 3475 | 3506 | var caretTrimReplace = '$1^' | |
| 3476 | 3507 | ||
| 3477 | 3508 | tok('CARET') | |
@@ -3493,6 +3524,7 @@ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + | |||
| 3493 | 3524 | ||
| 3494 | 3525 | // this one has to use the /g flag | |
| 3495 | 3526 | re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') | |
| 3527 | + safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), 'g') | ||
| 3496 | 3528 | var comparatorTrimReplace = '$1$2$3' | |
| 3497 | 3529 | ||
| 3498 | 3530 | // Something like `1.2.3 - 1.2.4` | |
@@ -3521,6 +3553,14 @@ for (var i = 0; i < R; i++) { | |||
| 3521 | 3553 | debug(i, src[i]) | |
| 3522 | 3554 | if (!re[i]) { | |
| 3523 | 3555 | re[i] = new RegExp(src[i]) | |
| 3556 | + | ||
| 3557 | + // Replace all greedy whitespace to prevent regex dos issues. These regex are | ||
| 3558 | + // used internally via the safeRe object since all inputs in this library get | ||
| 3559 | + // normalized first to trim and collapse all extra whitespace. The original | ||
| 3560 | + // regexes are exported for userland consumption and lower level usage. A | ||
| 3561 | + // future breaking change could export the safer regex only with a note that | ||
| 3562 | + // all input should have extra whitespace removed. | ||
| 3563 | + safeRe[i] = new RegExp(makeSafeRe(src[i])) | ||
| 3524 | 3564 | } | |
| 3525 | 3565 | } | |
| 3526 | 3566 | ||
@@ -3545,7 +3585,7 @@ function parse (version, options) { | |||
| 3545 | 3585 | return null | |
| 3546 | 3586 | } | |
| 3547 | 3587 | ||
| 3548 | - var r = options.loose ? re[t.LOOSE] : re[t.FULL] | ||
| 3588 | + var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL] | ||
| 3549 | 3589 | if (!r.test(version)) { | |
| 3550 | 3590 | return null | |
| 3551 | 3591 | } | |
@@ -3600,7 +3640,7 @@ function SemVer (version, options) { | |||
| 3600 | 3640 | this.options = options | |
| 3601 | 3641 | this.loose = !!options.loose | |
| 3602 | 3642 | ||
| 3603 | - var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) | ||
| 3643 | + var m = version.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]) | ||
| 3604 | 3644 | ||
| 3605 | 3645 | if (!m) { | |
| 3606 | 3646 | throw new TypeError('Invalid Version: ' + version) | |
@@ -4045,6 +4085,7 @@ function Comparator (comp, options) { | |||
| 4045 | 4085 | return new Comparator(comp, options) | |
| 4046 | 4086 | } | |
| 4047 | 4087 | ||
| 4088 | + comp = comp.trim().split(/\s+/).join(' ') | ||
| 4048 | 4089 | debug('comparator', comp, options) | |
| 4049 | 4090 | this.options = options | |
| 4050 | 4091 | this.loose = !!options.loose | |
@@ -4061,7 +4102,7 @@ function Comparator (comp, options) { | |||
| 4061 | 4102 | ||
| 4062 | 4103 | var ANY = {} | |
| 4063 | 4104 | Comparator.prototype.parse = function (comp) { | |
| 4064 | - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] | ||
| 4105 | + var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR] | ||
| 4065 | 4106 | var m = comp.match(r) | |
| 4066 | 4107 | ||
| 4067 | 4108 | if (!m) { | |
@@ -4185,17 +4226,24 @@ function Range (range, options) { | |||
| 4185 | 4226 | this.loose = !!options.loose | |
| 4186 | 4227 | this.includePrerelease = !!options.includePrerelease | |
| 4187 | 4228 | ||
| 4188 | - // First, split based on boolean or || | ||
| 4229 | + // First reduce all whitespace as much as possible so we do not have to rely | ||
| 4230 | + // on potentially slow regexes like \s*. This is then stored and used for | ||
| 4231 | + // future error messages as well. | ||
| 4189 | 4232 | this.raw = range | |
| 4190 | - this.set = range.split(/\s*\|\|\s*/).map(function (range) { | ||
| 4233 | + .trim() | ||
| 4234 | + .split(/\s+/) | ||
| 4235 | + .join(' ') | ||
| 4236 | + | ||
| 4237 | + // First, split based on boolean or || | ||
| 4238 | + this.set = this.raw.split('||').map(function (range) { | ||
| 4191 | 4239 | return this.parseRange(range.trim()) | |
| 4192 | 4240 | }, this).filter(function (c) { | |
| 4193 | 4241 | // throw out any that are not relevant for whatever reason | |
| 4194 | 4242 | return c.length | |
| 4195 | 4243 | }) | |
| 4196 | 4244 | ||
| 4197 | 4245 | if (!this.set.length) { | |
| 4198 | - throw new TypeError('Invalid SemVer Range: ' + range) | ||
| 4246 | + throw new TypeError('Invalid SemVer Range: ' + this.raw) | ||
| 4199 | 4247 | } | |
| 4200 | 4248 | ||
| 4201 | 4249 | this.format() | |
@@ -4214,28 +4262,27 @@ Range.prototype.toString = function () { | |||
| 4214 | 4262 | ||
| 4215 | 4263 | Range.prototype.parseRange = function (range) { | |
| 4216 | 4264 | var loose = this.options.loose | |
| 4217 | - range = range.trim() | ||
| 4218 | 4265 | // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` | |
| 4219 | - var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] | ||
| 4266 | + var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE] | ||
| 4220 | 4267 | range = range.replace(hr, hyphenReplace) | |
| 4221 | 4268 | debug('hyphen replace', range) | |
| 4222 | 4269 | // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` | |
| 4223 | - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) | ||
| 4224 | - debug('comparator trim', range, re[t.COMPARATORTRIM]) | ||
| 4270 | + range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace) | ||
| 4271 | + debug('comparator trim', range, safeRe[t.COMPARATORTRIM]) | ||
| 4225 | 4272 | ||
| 4226 | 4273 | // `~ 1.2.3` => `~1.2.3` | |
| 4227 | - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) | ||
| 4274 | + range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace) | ||
| 4228 | 4275 | ||
| 4229 | 4276 | // `^ 1.2.3` => `^1.2.3` | |
| 4230 | - range = range.replace(re[t.CARETTRIM], caretTrimReplace) | ||
| 4277 | + range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace) | ||
| 4231 | 4278 | ||
| 4232 | 4279 | // normalize spaces | |
| 4233 | 4280 | range = range.split(/\s+/).join(' ') | |
| 4234 | 4281 | ||
| 4235 | 4282 | // At this point, the range is completely trimmed and | |
| 4236 | 4283 | // ready to be split into comparators. | |
| 4237 | 4284 | ||
| 4238 | - var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] | ||
| 4285 | + var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR] | ||
| 4239 | 4286 | var set = range.split(' ').map(function (comp) { | |
| 4240 | 4287 | return parseComparator(comp, this.options) | |
| 4241 | 4288 | }, this).join(' ').split(/\s+/) | |
@@ -4335,7 +4382,7 @@ function replaceTildes (comp, options) { | |||
| 4335 | 4382 | } | |
| 4336 | 4383 | ||
| 4337 | 4384 | function replaceTilde (comp, options) { | |
| 4338 | - var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] | ||
| 4385 | + var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE] | ||
| 4339 | 4386 | return comp.replace(r, function (_, M, m, p, pr) { | |
| 4340 | 4387 | debug('tilde', comp, _, M, m, p, pr) | |
| 4341 | 4388 | var ret | |
@@ -4376,7 +4423,7 @@ function replaceCarets (comp, options) { | |||
| 4376 | 4423 | ||
| 4377 | 4424 | function replaceCaret (comp, options) { | |
| 4378 | 4425 | debug('caret', comp, options) | |
| 4379 | - var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] | ||
| 4426 | + var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET] | ||
| 4380 | 4427 | return comp.replace(r, function (_, M, m, p, pr) { | |
| 4381 | 4428 | debug('caret', comp, _, M, m, p, pr) | |
| 4382 | 4429 | var ret | |
@@ -4435,7 +4482,7 @@ function replaceXRanges (comp, options) { | |||
| 4435 | 4482 | ||
| 4436 | 4483 | function replaceXRange (comp, options) { | |
| 4437 | 4484 | comp = comp.trim() | |
| 4438 | - var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] | ||
| 4485 | + var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE] | ||
| 4439 | 4486 | return comp.replace(r, function (ret, gtlt, M, m, p, pr) { | |
| 4440 | 4487 | debug('xRange', comp, ret, gtlt, M, m, p, pr) | |
| 4441 | 4488 | var xM = isX(M) | |
@@ -4510,7 +4557,7 @@ function replaceXRange (comp, options) { | |||
| 4510 | 4557 | function replaceStars (comp, options) { | |
| 4511 | 4558 | debug('replaceStars', comp, options) | |
| 4512 | 4559 | // Looseness is ignored here. star is always as loose as it gets! | |
| 4513 | - return comp.trim().replace(re[t.STAR], '') | ||
| 4560 | + return comp.trim().replace(safeRe[t.STAR], '') | ||
| 4514 | 4561 | } | |
| 4515 | 4562 | ||
| 4516 | 4563 | // This function is passed to string.replace(re[t.HYPHENRANGE]) | |
@@ -4836,7 +4883,7 @@ function coerce (version, options) { | |||
| 4836 | 4883 | ||
| 4837 | 4884 | var match = null | |
| 4838 | 4885 | if (!options.rtl) { | |
| 4839 | - match = version.match(re[t.COERCE]) | ||
| 4886 | + match = version.match(safeRe[t.COERCE]) | ||
| 4840 | 4887 | } else { | |
| 4841 | 4888 | // Find the right-most coercible string that does not share | |
| 4842 | 4889 | // a terminus with a more left-ward coercible string. | |
@@ -4847,17 +4894,17 @@ function coerce (version, options) { | |||
| 4847 | 4894 | // Stop when we get a match that ends at the string end, since no | |
| 4848 | 4895 | // coercible string can be more right-ward without the same terminus. | |
| 4849 | 4896 | var next | |
| 4850 | - while ((next = re[t.COERCERTL].exec(version)) && | ||
| 4897 | + while ((next = safeRe[t.COERCERTL].exec(version)) && | ||
| 4851 | 4898 | (!match || match.index + match[0].length !== version.length) | |
| 4852 | 4899 | ) { | |
| 4853 | 4900 | if (!match || | |
| 4854 | 4901 | next.index + next[0].length !== match.index + match[0].length) { | |
| 4855 | 4902 | match = next | |
| 4856 | 4903 | } | |
| 4857 | - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length | ||
| 4904 | + safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length | ||
| 4858 | 4905 | } | |
| 4859 | 4906 | // leave it in a clean state | |
| 4860 | - re[t.COERCERTL].lastIndex = -1 | ||
| 4907 | + safeRe[t.COERCERTL].lastIndex = -1 | ||
| 4861 | 4908 | } | |
| 4862 | 4909 | ||
| 4863 | 4910 | if (match === null) { | |
@@ -59042,7 +59089,11 @@ module.exports = v4; | |||
| 59042 | 59089 | ||
| 59043 | 59090 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | |
| 59044 | 59091 | if (k2 === undefined) k2 = k; | |
| 59045 | - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| 59092 | + var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| 59093 | + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| 59094 | + desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| 59095 | + } | ||
| 59096 | + Object.defineProperty(o, k2, desc); | ||
| 59046 | 59097 | }) : (function(o, m, k, k2) { | |
| 59047 | 59098 | if (k2 === undefined) k2 = k; | |
| 59048 | 59099 | o[k2] = m[k]; | |
@@ -59151,7 +59202,11 @@ exports.CACHE_DEPENDENCY_BACKUP_PATH = '**/pyproject.toml'; | |||
| 59151 | 59202 | ||
| 59152 | 59203 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | |
| 59153 | 59204 | if (k2 === undefined) k2 = k; | |
| 59154 | - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| 59205 | + var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| 59206 | + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| 59207 | + desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| 59208 | + } | ||
| 59209 | + Object.defineProperty(o, k2, desc); | ||
| 59155 | 59210 | }) : (function(o, m, k, k2) { | |
| 59156 | 59211 | if (k2 === undefined) k2 = k; | |
| 59157 | 59212 | o[k2] = m[k]; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments