Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
This PR fixes
isInvalidVersionincore/parcel-transformer-manifest/src/validate-version.ts, which could never returntrue(!isNaN(num) && num < 0 && num > 65536). As a result,validateSemanticVersion/validateBrowserVersion(used forversionandminimum_chrome_versionin the MV2/MV3 schemas) rejected only versions with too many segments, and the 0..65535 range in their error message was never checked.Fixes #1362
Approach
/^\d+$/) no greater than 65535. The digit check is needed becauseNumber()turns""," 1","1e3"and"0x10"into numbers, so fixing only the&&/NaNlogic would still let empty segments like1..0through.1..3.4reports the segment error. Inputs with valid segments but too many of them (4 forversion, 5 forminimum_chrome_version) keep the existing... to have at most N dotsmessage.firefox/geckobuilds (PLASMO_BROWSER), the transformer validates with a copy of the schema whoseversionhook keeps the previous check (more than 3 segments fails, nothing else does), so Firefox builds behave exactly as before. The copy is picked on each transform; the shared schemas and both validators are not changed by it.minimum_chrome_versionis checked strictly on every target.version0,1.2.3,65535.65535.6553570000.0.0,65536... must be dot-separated integers between 0 and 65535abc.def,1.0.0-beta,1.0.0+build,-1.0.0,1..0,"",1e3... must be dot-separated integers between 0 and 655351..3.4(version)at most 3 dots... must be dot-separated integers between 0 and 65535at most 3 dots(unchanged)1.2.3.4(version)at most 3 dotsat most 3 dotsat most 3 dots(unchanged)The default
versioncomes frompackage.json(manifest overrides can replace it). A Chrome build whose version has a prerelease suffix such as1.0.0-betanow gets this error at build time instead of Chrome rejecting the manifest later.To reproduce (Node 22.18+ runs the
.tsfile directly), from the repo root:node -e 'import("./core/parcel-transformer-manifest/src/validate-version.ts").then((m) => { for (const v of ["1.2.3", "abc.def", "1.0.0-beta", "-1.0.0", "70000.0.0", "1..0", "1..3.4"]) console.log(JSON.stringify(v), "->", m.validateSemanticVersion(v), "|", m.validateBrowserVersion(v)) })'On
mainevery line except1..3.4printsundefined | undefined. With this change every line except1.2.3prints themust be dot-separated integers between 0 and 65535error for both validators. This package has no test runner; I also checked the MV2 and MV3 schemas picked for no target, chrome, edge, firefox and gecko with an assertion script, including that both validators stay strict after a Firefox schema was picked.Known limitations
versioncheck: at most 3 segments, nothing else. Firefox itself accepts any version string with a warning; Firefox's recommended format and AMO's submission rules are not checked.01) and all-zero versions are still accepted, and four-segment extension versions are still rejected.Code of Conduct
Contacts
If your PR is accepted, we will award you with the
Contributorrole on Discord server.To join the server, visit: https://www.plasmo.com/s/d