Skip to content

Harden compareVersions to strip pre-release suffixes#891

Open
JonahBraun wants to merge 1 commit into
mainfrom
fix/harden-compareVersions
Open

Harden compareVersions to strip pre-release suffixes#891
JonahBraun wants to merge 1 commit into
mainfrom
fix/harden-compareVersions

Conversation

@JonahBraun
Copy link
Copy Markdown
Contributor

Align MetadataManager's local compareVersions() with the hardened implementation shipped in frontier-authentication's extensionVersionChecker.ts (PR #25).

The old implementation used split(".").map(parseInt) which relied on parseInt silently stopping at hyphens in pre-release suffixes like -pr123. This worked by accident but was fragile and inconsistent with the explicit regex-based parsing used elsewhere.

Changes

  • Add extractCoreVersionParts() — regex extracts [major, minor, patch] from version strings, properly ignoring pre-release suffixes (-pr123, -pr123-shorthash) and v prefixes
  • Rewrite compareVersions() to use it, throwing on unparseable input instead of silently producing wrong results

Test plan

  • npm run compile passes (no new errors)
  • Versions like 0.24.1, 0.24.1-pr123, 0.24.1-pr123-abc1234, v0.24.1 all compare correctly
  • Ratchet suppression in ensureExtensionVersionsRecorded still works (callers unchanged)

The local compareVersions() in MetadataManager used naive split/parseInt
parsing that relied on parseInt stopping at hyphens. Replace with
extractCoreVersionParts() using an explicit regex, matching the hardened
implementation in frontier-authentication's extensionVersionChecker.ts.
@JonahBraun
Copy link
Copy Markdown
Contributor Author

/build

@github-actions
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant