@@ -54,13 +54,13 @@ export function sparkleBuildFloorsFromShortVersion(
5454 return null ;
5555 }
5656
57- const year = Number . parseInt ( match [ 1 ] , 10 ) ;
58- const month = Number . parseInt ( match [ 2 ] , 10 ) ;
59- const patch = Number . parseInt ( match [ 3 ] , 10 ) ;
57+ const year = Number ( match [ 1 ] ) ;
58+ const month = Number ( match [ 2 ] ) ;
59+ const patch = Number ( match [ 3 ] ) ;
6060 if (
61- ! Number . isInteger ( year ) ||
62- ! Number . isInteger ( month ) ||
63- ! Number . isInteger ( patch ) ||
61+ ! Number . isSafeInteger ( year ) ||
62+ ! Number . isSafeInteger ( month ) ||
63+ ! Number . isSafeInteger ( patch ) ||
6464 month < 1 ||
6565 month > 12 ||
6666 patch < 1
@@ -87,24 +87,39 @@ export function sparkleBuildFloorsFromShortVersion(
8787 // Keep old appcast entries byte-stable, then switch to YYMMPPPPLL so
8888 // monthly patches beyond 31 stay monotonic without pretending to be dates.
8989 const releaseKey = monthlyPatchReleaseKey ( year , month , patch ) ;
90+ const laneFloor = releaseKey + lane ;
91+ if ( ! isSafeSparkleFloor ( releaseKey ) || ! isSafeSparkleFloor ( laneFloor ) ) {
92+ return null ;
93+ }
9094 return {
9195 releaseKey,
9296 legacyFloor : releaseKey ,
93- laneFloor : releaseKey + lane ,
97+ laneFloor,
9498 lane,
9599 } ;
96100 }
97101
98102 const releaseKey = legacyDateReleaseKey ( year , month , patch ) ;
99103 const legacyFloor = Number ( `${ releaseKey } 0` ) ;
100104 const laneFloor = Number ( `${ releaseKey } ${ String ( lane ) . padStart ( 2 , "0" ) } ` ) ;
105+ if (
106+ ! isSafeSparkleFloor ( releaseKey ) ||
107+ ! isSafeSparkleFloor ( legacyFloor ) ||
108+ ! isSafeSparkleFloor ( laneFloor )
109+ ) {
110+ return null ;
111+ }
101112 return { releaseKey, legacyFloor, laneFloor, lane } ;
102113}
103114
104115export function canonicalSparkleBuildFromVersion ( shortVersion : string ) : number | null {
105116 return sparkleBuildFloorsFromShortVersion ( shortVersion ) ?. laneFloor ?? null ;
106117}
107118
119+ function isSafeSparkleFloor ( value : number ) : boolean {
120+ return Number . isSafeInteger ( value ) && value > 0 ;
121+ }
122+
108123function runCli ( args : string [ ] ) : number {
109124 const [ command , version ] = args ;
110125 if ( command !== "canonical-build" || ! version ) {
0 commit comments