@@ -45,26 +45,26 @@ export const JUNE_2026_PATCH_FLOOR = 5;
|
45 | 45 | * @returns {ParsedReleaseVersion | null} |
46 | 46 | */ |
47 | 47 | function parseVersionParts(version, groups, channel) { |
48 | | -const year = Number.parseInt(groups.year ?? "", 10); |
49 | | -const month = Number.parseInt(groups.month ?? "", 10); |
50 | | -const patch = Number.parseInt(groups.patch ?? "", 10); |
51 | | -const alphaNumber = channel === "alpha" ? Number.parseInt(groups.alpha ?? "", 10) : undefined; |
52 | | -const betaNumber = channel === "beta" ? Number.parseInt(groups.beta ?? "", 10) : undefined; |
| 48 | +const year = parseSafeIntegerPart(groups.year); |
| 49 | +const month = parseSafeIntegerPart(groups.month); |
| 50 | +const patch = parseSafeIntegerPart(groups.patch); |
| 51 | +const alphaNumber = channel === "alpha" ? parseSafeIntegerPart(groups.alpha) : undefined; |
| 52 | +const betaNumber = channel === "beta" ? parseSafeIntegerPart(groups.beta) : undefined; |
53 | 53 | |
54 | 54 | if ( |
55 | | -!Number.isInteger(year) || |
56 | | -!Number.isInteger(month) || |
57 | | -!Number.isInteger(patch) || |
| 55 | +!Number.isSafeInteger(year) || |
| 56 | +!Number.isSafeInteger(month) || |
| 57 | +!Number.isSafeInteger(patch) || |
58 | 58 | month < 1 || |
59 | 59 | month > 12 || |
60 | 60 | patch < 1 |
61 | 61 | ) { |
62 | 62 | return null; |
63 | 63 | } |
64 | | -if (channel === "beta" && (!Number.isInteger(betaNumber) || (betaNumber ?? 0) < 1)) { |
| 64 | +if (channel === "beta" && (!Number.isSafeInteger(betaNumber) || (betaNumber ?? 0) < 1)) { |
65 | 65 | return null; |
66 | 66 | } |
67 | | -if (channel === "alpha" && (!Number.isInteger(alphaNumber) || (alphaNumber ?? 0) < 1)) { |
| 67 | +if (channel === "alpha" && (!Number.isSafeInteger(alphaNumber) || (alphaNumber ?? 0) < 1)) { |
68 | 68 | return null; |
69 | 69 | } |
70 | 70 | |
@@ -80,6 +80,15 @@ function parseVersionParts(version, groups, channel) {
|
80 | 80 | }; |
81 | 81 | } |
82 | 82 | |
| 83 | +function parseSafeIntegerPart(value) { |
| 84 | +const raw = value ?? ""; |
| 85 | +if (!/^[0-9]+$/.test(raw)) { |
| 86 | +return null; |
| 87 | +} |
| 88 | +const parsed = Number(raw); |
| 89 | +return Number.isSafeInteger(parsed) ? parsed : null; |
| 90 | +} |
| 91 | + |
83 | 92 | /** |
84 | 93 | * @param {string} version |
85 | 94 | * @returns {ParsedReleaseVersion | null} |
@@ -108,8 +117,12 @@ export function parseReleaseVersion(version) {
|
108 | 117 | const correctionMatch = CORRECTION_VERSION_REGEX.exec(trimmed); |
109 | 118 | if (correctionMatch?.groups) { |
110 | 119 | const parsedCorrection = parseVersionParts(trimmed, correctionMatch.groups, "stable"); |
111 | | -const correctionNumber = Number.parseInt(correctionMatch.groups.correction ?? "", 10); |
112 | | -if (parsedCorrection === null || !Number.isInteger(correctionNumber) || correctionNumber < 1) { |
| 120 | +const correctionNumber = parseSafeIntegerPart(correctionMatch.groups.correction); |
| 121 | +if ( |
| 122 | +parsedCorrection === null || |
| 123 | +!Number.isSafeInteger(correctionNumber) || |
| 124 | +correctionNumber < 1 |
| 125 | +) { |
113 | 126 | return null; |
114 | 127 | } |
115 | 128 | |
|