@@ -8834,15 +8834,18 @@ class Range {
88348834 const hr = loose ? re [ t . HYPHENRANGELOOSE ] : re [ t . HYPHENRANGE ]
88358835 range = range . replace ( hr , hyphenReplace ( this . options . includePrerelease ) )
88368836 debug ( 'hyphen replace' , range )
8837+
88378838 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
88388839 range = range . replace ( re [ t . COMPARATORTRIM ] , comparatorTrimReplace )
88398840 debug ( 'comparator trim' , range )
88408841
88418842 // `~ 1.2.3` => `~1.2.3`
88428843 range = range . replace ( re [ t . TILDETRIM ] , tildeTrimReplace )
8844+ debug ( 'tilde trim' , range )
88438845
88448846 // `^ 1.2.3` => `^1.2.3`
88458847 range = range . replace ( re [ t . CARETTRIM ] , caretTrimReplace )
8848+ debug ( 'caret trim' , range )
88468849
88478850 // At this point, the range is completely trimmed and
88488851 // ready to be split into comparators.
@@ -10144,6 +10147,10 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
1014410147// Max safe segment length for coercion.
1014510148const MAX_SAFE_COMPONENT_LENGTH = 16
1014610149
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+
1014710154const RELEASE_TYPES = [
1014810155 'major' ,
1014910156 'premajor' ,
@@ -10157,6 +10164,7 @@ const RELEASE_TYPES = [
1015710164module . exports = {
1015810165 MAX_LENGTH ,
1015910166 MAX_SAFE_COMPONENT_LENGTH ,
10167+ MAX_SAFE_BUILD_LENGTH ,
1016010168 MAX_SAFE_INTEGER ,
1016110169 RELEASE_TYPES ,
1016210170 SEMVER_SPEC_VERSION ,
@@ -10238,7 +10246,7 @@ module.exports = parseOptions
1023810246/***/ 9523 :
1023910247/***/ ( ( module , exports , __nccwpck_require__ ) => {
1024010248
10241- const { MAX_SAFE_COMPONENT_LENGTH } = __nccwpck_require__ ( 2293 )
10249+ const { MAX_SAFE_COMPONENT_LENGTH , MAX_SAFE_BUILD_LENGTH } = __nccwpck_require__ ( 2293 )
1024210250const debug = __nccwpck_require__ ( 427 )
1024310251exports = module . exports = { }
1024410252
@@ -10249,16 +10257,31 @@ const src = exports.src = []
1024910257const t = exports . t = { }
1025010258let R = 0
1025110259
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+
1025210283const 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 )
1026210285 const index = R ++
1026310286 debug ( name , index , value )
1026410287 t [ name ] = index
@@ -10274,13 +10297,13 @@ const createToken = (name, value, isGlobal) => {
1027410297// A single `0`, or a non-zero digit followed by zero or more digits.
1027510298
1027610299createToken ( 'NUMERICIDENTIFIER' , '0|[1-9]\\d*' )
10277- createToken ( 'NUMERICIDENTIFIERLOOSE' , '[0-9] +' )
10300+ createToken ( 'NUMERICIDENTIFIERLOOSE' , '\\d +' )
1027810301
1027910302// ## Non-numeric Identifier
1028010303// Zero or more digits, followed by a letter or hyphen, and then zero or
1028110304// more letters, digits, or hyphens.
1028210305
10283- createToken ( 'NONNUMERICIDENTIFIER' , ' \\d*[a-zA-Z-][a-zA-Z0-9-]*' )
10306+ createToken ( 'NONNUMERICIDENTIFIER' , ` \\d*[a-zA-Z-]${ LETTERDASHNUMBER } *` )
1028410307
1028510308// ## Main Version
1028610309// Three dot-separated numeric identifiers.
@@ -10315,7 +10338,7 @@ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
1031510338// ## Build Metadata Identifier
1031610339// Any combination of digits, letters, or hyphens.
1031710340
10318- createToken ( 'BUILDIDENTIFIER' , '[0-9A-Za-z-]+' )
10341+ createToken ( 'BUILDIDENTIFIER' , ` ${ LETTERDASHNUMBER } +` )
1031910342
1032010343// ## Build Metadata
1032110344// Plus sign, followed by one or more period-separated build metadata
0 commit comments