@@ -8834,15 +8834,18 @@ class Range {
8834
8834
const hr = loose ? re [ t . HYPHENRANGELOOSE ] : re [ t . HYPHENRANGE ]
8835
8835
range = range . replace ( hr , hyphenReplace ( this . options . includePrerelease ) )
8836
8836
debug ( 'hyphen replace' , range )
8837
+
8837
8838
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
8838
8839
range = range . replace ( re [ t . COMPARATORTRIM ] , comparatorTrimReplace )
8839
8840
debug ( 'comparator trim' , range )
8840
8841
8841
8842
// `~ 1.2.3` => `~1.2.3`
8842
8843
range = range . replace ( re [ t . TILDETRIM ] , tildeTrimReplace )
8844
+ debug ( 'tilde trim' , range )
8843
8845
8844
8846
// `^ 1.2.3` => `^1.2.3`
8845
8847
range = range . replace ( re [ t . CARETTRIM ] , caretTrimReplace )
8848
+ debug ( 'caret trim' , range )
8846
8849
8847
8850
// At this point, the range is completely trimmed and
8848
8851
// ready to be split into comparators.
@@ -10144,6 +10147,10 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
10144
10147
// Max safe segment length for coercion.
10145
10148
const MAX_SAFE_COMPONENT_LENGTH = 16
10146
10149
10150
+ // Max safe length for a build identifier. The max length minus 6 characters for
10151
+ // the shortest version with a build 0.0.0+BUILD.
10152
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
10153
+
10147
10154
const RELEASE_TYPES = [
10148
10155
'major' ,
10149
10156
'premajor' ,
@@ -10157,6 +10164,7 @@ const RELEASE_TYPES = [
10157
10164
module . exports = {
10158
10165
MAX_LENGTH ,
10159
10166
MAX_SAFE_COMPONENT_LENGTH ,
10167
+ MAX_SAFE_BUILD_LENGTH ,
10160
10168
MAX_SAFE_INTEGER ,
10161
10169
RELEASE_TYPES ,
10162
10170
SEMVER_SPEC_VERSION ,
@@ -10238,7 +10246,7 @@ module.exports = parseOptions
10238
10246
/***/ 9523 :
10239
10247
/***/ ( ( module , exports , __nccwpck_require__ ) => {
10240
10248
10241
- const { MAX_SAFE_COMPONENT_LENGTH } = __nccwpck_require__ ( 2293 )
10249
+ const { MAX_SAFE_COMPONENT_LENGTH , MAX_SAFE_BUILD_LENGTH } = __nccwpck_require__ ( 2293 )
10242
10250
const debug = __nccwpck_require__ ( 427 )
10243
10251
exports = module . exports = { }
10244
10252
@@ -10249,16 +10257,31 @@ const src = exports.src = []
10249
10257
const t = exports . t = { }
10250
10258
let R = 0
10251
10259
10260
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
10261
+
10262
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
10263
+ // used internally via the safeRe object since all inputs in this library get
10264
+ // normalized first to trim and collapse all extra whitespace. The original
10265
+ // regexes are exported for userland consumption and lower level usage. A
10266
+ // future breaking change could export the safer regex only with a note that
10267
+ // all input should have extra whitespace removed.
10268
+ const safeRegexReplacements = [
10269
+ [ '\\s' , 1 ] ,
10270
+ [ '\\d' , MAX_SAFE_COMPONENT_LENGTH ] ,
10271
+ [ LETTERDASHNUMBER , MAX_SAFE_BUILD_LENGTH ] ,
10272
+ ]
10273
+
10274
+ const makeSafeRegex = ( value ) => {
10275
+ for ( const [ token , max ] of safeRegexReplacements ) {
10276
+ value = value
10277
+ . split ( `${ token } *` ) . join ( `${ token } {0,${ max } }` )
10278
+ . split ( `${ token } +` ) . join ( `${ token } {1,${ max } }` )
10279
+ }
10280
+ return value
10281
+ }
10282
+
10252
10283
const createToken = ( name , value , isGlobal ) => {
10253
- // Replace all greedy whitespace to prevent regex dos issues. These regex are
10254
- // used internally via the safeRe object since all inputs in this library get
10255
- // normalized first to trim and collapse all extra whitespace. The original
10256
- // regexes are exported for userland consumption and lower level usage. A
10257
- // future breaking change could export the safer regex only with a note that
10258
- // all input should have extra whitespace removed.
10259
- const safe = value
10260
- . split ( '\\s*' ) . join ( '\\s{0,1}' )
10261
- . split ( '\\s+' ) . join ( '\\s' )
10284
+ const safe = makeSafeRegex ( value )
10262
10285
const index = R ++
10263
10286
debug ( name , index , value )
10264
10287
t [ name ] = index
@@ -10274,13 +10297,13 @@ const createToken = (name, value, isGlobal) => {
10274
10297
// A single `0`, or a non-zero digit followed by zero or more digits.
10275
10298
10276
10299
createToken ( 'NUMERICIDENTIFIER' , '0|[1-9]\\d*' )
10277
- createToken ( 'NUMERICIDENTIFIERLOOSE' , '[0-9] +' )
10300
+ createToken ( 'NUMERICIDENTIFIERLOOSE' , '\\d +' )
10278
10301
10279
10302
// ## Non-numeric Identifier
10280
10303
// Zero or more digits, followed by a letter or hyphen, and then zero or
10281
10304
// more letters, digits, or hyphens.
10282
10305
10283
- createToken ( 'NONNUMERICIDENTIFIER' , ' \\d*[a-zA-Z-][a-zA-Z0-9-]*' )
10306
+ createToken ( 'NONNUMERICIDENTIFIER' , ` \\d*[a-zA-Z-]${ LETTERDASHNUMBER } *` )
10284
10307
10285
10308
// ## Main Version
10286
10309
// Three dot-separated numeric identifiers.
@@ -10315,7 +10338,7 @@ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
10315
10338
// ## Build Metadata Identifier
10316
10339
// Any combination of digits, letters, or hyphens.
10317
10340
10318
- createToken ( 'BUILDIDENTIFIER' , '[0-9A-Za-z-]+' )
10341
+ createToken ( 'BUILDIDENTIFIER' , ` ${ LETTERDASHNUMBER } +` )
10319
10342
10320
10343
// ## Build Metadata
10321
10344
// Plus sign, followed by one or more period-separated build metadata
0 commit comments