Repository navigation
fix(resolving): reject malformed jsr: and named-registry package names (empty scope/name, path separators) - #12677
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR tightens package-name validation in the JSR and named-registry specifier parsers, rejecting malformed scopes, empty names, and path-separator variants with invalid-package-name errors. It also expands test coverage and adds changeset entries. ChangesSpecifier package-name validation
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix JSR specifier parsing: reject scoped specifiers with empty package name Description
Diagram
High-Level Assessment
Files changed (3)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts (1)
45-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDrop the redundant comment.
Line 45 just restates the assertion below, so it adds noise without clarifying intent. As per coding guidelines, "Do not write comments that restate what the code already says."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts` at line 45, Remove the redundant inline comment in the jsr-specifier-parser test that simply restates the empty scoped package case; update the `parse.test.ts` test near the `jsr:`@scope/`` assertion to rely on the assertion name/value itself instead of the extra comment.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/jsr-specifier-empty-name.md:
- Line 5: Update the changeset summary to mention pnpm explicitly and describe
the user-visible behavior change concisely: the release note should state that
pnpm rejects `jsr:`@scope/`` specifiers with an empty package name instead of
silently producing a malformed npm package name. Keep the wording accurate for
the parser change and ensure the `.changeset` entry reflects the correct bump
type.
---
Nitpick comments:
In `@pnpm11/resolving/jsr-specifier-parser/test/parse.test.ts`:
- Line 45: Remove the redundant inline comment in the jsr-specifier-parser test
that simply restates the empty scoped package case; update the `parse.test.ts`
test near the `jsr:`@scope/`` assertion to rely on the assertion name/value itself
instead of the extra comment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f006de3a-6975-4234-a5d0-1051537cb3de
📒 Files selected for processing (3)
.changeset/jsr-specifier-empty-name.mdpnpm11/resolving/jsr-specifier-parser/src/index.tspnpm11/resolving/jsr-specifier-parser/test/parse.test.ts
Code Review by Qodo
1. JSR name path injection
|
|
Code review by qodo was updated up to the latest commit 5ae3b61 |
…cope/` with empty package name `jsr:@scope/` (scope with trailing slash, no package name) was parsed by jsrToNpmPackageName as if it were a valid specifier, producing the malformed npm package name `@jsr/scope__` (empty name after `__`) and returning without error. The fix adds a guard after the slash-split to throw INVALID_JSR_PACKAGE_NAME when the name segment is empty, matching the existing error path for `jsr:@scope` (no slash at all).
5ae3b61 to
aa1be79
Compare
|
Code review by qodo was updated up to the latest commit aa1be79 |
1 similar comment
|
Code review by qodo was updated up to the latest commit aa1be79 |
… stacks Broaden the empty-name guard per review: also reject an empty scope (`jsr:@/bar`) and path separators in the name segment (`jsr:@foo/../bar`, backslashes). The generated `@jsr/...` npm package name flows into registry URLs and metadata cache file paths, so extra separators were a path-injection risk. Mirror the same validation in pacquet's resolving-jsr-specifier-parser crate, with matching tests, and note the "pnpm" package in the changeset.
@scope/ with empty package namejsr: package names (empty scope/name, path separators)
|
Code review by qodo was updated up to the latest commit 2d368ac |
|
Code review by qodo was updated up to the latest commit 2d368ac |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12677 +/- ##
==========================================
+ Coverage 85.55% 85.62% +0.06%
==========================================
Files 413 413
Lines 63908 64335 +427
==========================================
+ Hits 54679 55088 +409
- Misses 9229 9247 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.0056362105,
"stddev": 0.12616967496069192,
"median": 3.9495244986,
"user": 3.8248342200000005,
"system": 3.45871364,
"min": 3.8660412096,
"max": 4.2656306216,
"times": [
4.0238537176,
4.2656306216,
3.9198250536000003,
4.086659335599999,
4.1508548056,
3.9618704896000003,
3.9348649116,
3.9371785076,
3.9095834526,
3.8660412096
]
},
{
"command": "pacquet@main",
"mean": 4.022186454200001,
"stddev": 0.16129750737736406,
"median": 3.9966046056,
"user": 3.81939242,
"system": 3.4360019399999997,
"min": 3.8432087206000003,
"max": 4.2987860026,
"times": [
4.2987860026,
4.2456786825999995,
4.0469596646,
3.8896124696000003,
3.9462495466000003,
4.0546811736,
3.8432087206000003,
4.130906555599999,
3.8863822526000003,
3.8793994736000004
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1219819351,
"stddev": 0.12536657110902802,
"median": 2.1059245256000003,
"user": 2.6014214199999994,
"system": 2.9905332400000004,
"min": 1.9630437576,
"max": 2.2712698746,
"times": [
2.0961164456000003,
1.9630437576,
2.2696241086,
2.2236297466000003,
2.0123659146,
2.2712698746,
2.0101002846,
2.2639375626000002,
2.1157326056000003,
1.9939990506
]
},
{
"command": "pnpr@main",
"mean": 2.2166520278000004,
"stddev": 0.10348008640754719,
"median": 2.1961377971000005,
"user": 2.621982719999999,
"system": 2.9471531399999997,
"min": 2.0453367746,
"max": 2.3513962996,
"times": [
2.3053407056000004,
2.1592988756000002,
2.0453367746,
2.3513962996,
2.1781893006,
2.2140862936000003,
2.3279423426,
2.1587489146000003,
2.1119382366000004,
2.3142425346000004
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6364346540200001,
"stddev": 0.012192720464231914,
"median": 0.6409637825200001,
"user": 0.36784668,
"system": 1.3181179,
"min": 0.61736196152,
"max": 0.64938602652,
"times": [
0.61736196152,
0.6439398955200001,
0.64774873552,
0.64938602652,
0.62303320252,
0.6212247725200001,
0.64702044552,
0.63162918052,
0.6450146505200001,
0.6379876695200001
]
},
{
"command": "pacquet@main",
"mean": 0.62957485182,
"stddev": 0.014385923383705843,
"median": 0.62942718202,
"user": 0.35852548,
"system": 1.3172837999999998,
"min": 0.60792741252,
"max": 0.64810015352,
"times": [
0.62215303052,
0.62755075752,
0.6313036065200001,
0.62114050052,
0.6452513295200001,
0.64065660552,
0.64197134552,
0.64810015352,
0.60969377652,
0.60792741252
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6869789344200001,
"stddev": 0.05072568356888418,
"median": 0.67336599852,
"user": 0.37668818000000004,
"system": 1.3396289999999997,
"min": 0.6478100815200001,
"max": 0.82298254352,
"times": [
0.71020773752,
0.66369966352,
0.6478100815200001,
0.67560373052,
0.67112826652,
0.6808128155200001,
0.6794248205200001,
0.66135072752,
0.6567689575200001,
0.82298254352
]
},
{
"command": "pnpr@main",
"mean": 0.70875078642,
"stddev": 0.02170818446443872,
"median": 0.71138790702,
"user": 0.37924448,
"system": 1.3705843999999998,
"min": 0.67878378852,
"max": 0.74165985152,
"times": [
0.74165985152,
0.73175203952,
0.67878378852,
0.71335017152,
0.68039783452,
0.73034641252,
0.71039142252,
0.6951101995200001,
0.71238439152,
0.69333175252
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.15546584738,
"stddev": 0.0367228454747338,
"median": 4.1642490294800005,
"user": 3.7019722799999997,
"system": 3.31943738,
"min": 4.08316323748,
"max": 4.20705918648,
"times": [
4.18336539448,
4.1328178734800005,
4.08316323748,
4.165912505480001,
4.117445876480001,
4.1625855534800005,
4.14524152548,
4.18807633048,
4.20705918648,
4.16899099048
]
},
{
"command": "pacquet@main",
"mean": 4.18143007688,
"stddev": 0.05493465466077461,
"median": 4.18207019098,
"user": 3.7227821800000003,
"system": 3.3248651799999998,
"min": 4.11045335748,
"max": 4.27733095548,
"times": [
4.27733095548,
4.12618715648,
4.23795786348,
4.1415088974800005,
4.131185110480001,
4.11045335748,
4.17419698848,
4.18994339348,
4.228118680480001,
4.19741836548
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1725372868800004,
"stddev": 0.13595484616342873,
"median": 2.14488310798,
"user": 2.4502945800000004,
"system": 2.88412328,
"min": 2.0188621504800004,
"max": 2.41037242148,
"times": [
2.2976115054800004,
2.14076282048,
2.0488901894800002,
2.1490033954800003,
2.06296163948,
2.41037242148,
2.35630224248,
2.0188621504800004,
2.0853526644800002,
2.1552538394800003
]
},
{
"command": "pnpr@main",
"mean": 2.1387291081800006,
"stddev": 0.12450720824432178,
"median": 2.07984415798,
"user": 2.4679212799999997,
"system": 2.86958058,
"min": 2.0087135334800004,
"max": 2.3899014854800003,
"times": [
2.06266805148,
2.1926449704800004,
2.2459522734800004,
2.03914546848,
2.3899014854800003,
2.0970202644800002,
2.2493980284800004,
2.05356851348,
2.04827849248,
2.0087135334800004
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3118978072999998,
"stddev": 0.014454154306708497,
"median": 1.3074907550000001,
"user": 1.2823868000000003,
"system": 1.6643307999999997,
"min": 1.2949836435000002,
"max": 1.3407934045,
"times": [
1.3038913285,
1.2992780915000002,
1.3124781635,
1.3101388135,
1.3018877295000002,
1.3048426965000002,
1.2949836435000002,
1.3285819005000001,
1.3221023015000002,
1.3407934045
]
},
{
"command": "pacquet@main",
"mean": 1.3489121831000002,
"stddev": 0.09968237585881036,
"median": 1.315974765,
"user": 1.2984743,
"system": 1.6755729,
"min": 1.3057929725000001,
"max": 1.6309404255,
"times": [
1.3137717335,
1.3164226025,
1.6309404255,
1.3057929725000001,
1.3416736495000001,
1.3155269275,
1.3097776695,
1.3197424815,
1.3066374075,
1.3288359615
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6633434572999999,
"stddev": 0.06095452423281082,
"median": 0.645141008,
"user": 0.32123669999999993,
"system": 1.2788513000000001,
"min": 0.6276907765,
"max": 0.8352247705,
"times": [
0.6416219055,
0.6402606925,
0.6511648595,
0.6402671955,
0.6395437915,
0.6276907765,
0.8352247705,
0.6551654004999999,
0.6486601104999999,
0.6538350705
]
},
{
"command": "pnpr@main",
"mean": 0.6446307398,
"stddev": 0.005643391748412421,
"median": 0.6459352295,
"user": 0.3244979,
"system": 1.2686042000000002,
"min": 0.6362327005,
"max": 0.6529167835,
"times": [
0.6529167835,
0.6364616095,
0.6485022095,
0.6412848185,
0.6490882575,
0.6362327005,
0.6411415655,
0.6488089945,
0.6468358104999999,
0.6450346485
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0045481645000005,
"stddev": 0.03390807553862202,
"median": 3.0036928432000005,
"user": 1.7455229200000002,
"system": 1.95695092,
"min": 2.9679821252000003,
"max": 3.0806193112,
"times": [
3.0342289782000003,
3.0007758682000003,
2.9855029632,
3.0088485582,
2.9679821252000003,
3.0119366062,
2.9808741752000003,
3.0806193112,
2.9681032412,
3.0066098182000003
]
},
{
"command": "pacquet@main",
"mean": 2.9757771449000003,
"stddev": 0.055302278785092314,
"median": 2.9644057742000003,
"user": 1.7459214199999997,
"system": 1.95011872,
"min": 2.9276162132000003,
"max": 3.1259827912,
"times": [
2.9803401882,
2.9795340702,
2.9700004242,
2.9515287002000004,
2.9448034352000003,
2.9588922052,
2.9699193432000004,
3.1259827912,
2.9491540782000003,
2.9276162132000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6633370109,
"stddev": 0.011014542430201547,
"median": 0.6626708547,
"user": 0.32270941999999997,
"system": 1.2974386199999999,
"min": 0.6497596312,
"max": 0.6858364912,
"times": [
0.6858364912,
0.6587548412,
0.6637002182,
0.6572898302000001,
0.6625240952,
0.6766487672,
0.6653991312,
0.6506394892,
0.6497596312,
0.6628176142000001
]
},
{
"command": "pnpr@main",
"mean": 0.6511300593,
"stddev": 0.006009927558261722,
"median": 0.6540373302000001,
"user": 0.33061942,
"system": 1.2695903199999998,
"min": 0.6412426052000001,
"max": 0.6581678572,
"times": [
0.6445458982000001,
0.6581678572,
0.6482063582,
0.6562506322,
0.6556555442,
0.6549366302,
0.6541848212000001,
0.6442204072000001,
0.6412426052000001,
0.6538898392000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.81654523842,
"stddev": 0.1525172075511404,
"median": 6.812667021219999,
"user": 3.9761263,
"system": 3.7369768599999986,
"min": 6.61181375122,
"max": 7.16563659722,
"times": [
6.7143106572199995,
6.81940631222,
6.61181375122,
6.85167018922,
6.86792255522,
6.90855924622,
6.70943414122,
7.16563659722,
6.80592773022,
6.71077120422
]
},
{
"command": "pacquet@main",
"mean": 6.817951988520001,
"stddev": 0.14670840750385714,
"median": 6.79155502022,
"user": 3.9799764999999994,
"system": 3.7264006599999995,
"min": 6.60053783922,
"max": 7.01010277122,
"times": [
7.01010277122,
6.84106245522,
6.70852796022,
6.80797804622,
6.75286247822,
7.00025348522,
6.67345975722,
6.60053783922,
6.77513199422,
7.00960309822
]
},
{
"command": "pnpr@HEAD",
"mean": 4.951087080620001,
"stddev": 0.14163680482267002,
"median": 4.91614297022,
"user": 2.7127733999999997,
"system": 3.20011066,
"min": 4.75192723422,
"max": 5.18149578222,
"times": [
4.82656696122,
5.05882948222,
4.97920256922,
4.75192723422,
5.18149578222,
5.15082426322,
4.89917046422,
4.8323761452200005,
4.89736242822,
4.93311547622
]
},
{
"command": "pnpr@main",
"mean": 4.95407932732,
"stddev": 0.09180907022379446,
"median": 4.93573687922,
"user": 2.7175761999999994,
"system": 3.2030685599999997,
"min": 4.80908792822,
"max": 5.1212584442199995,
"times": [
4.96304502722,
4.95933228722,
4.94228185922,
4.92919189922,
5.1212584442199995,
4.90880422222,
4.80908792822,
4.89910885622,
5.09349884522,
4.91518390422
]
}
]
} |
|
| Branch | pr/12677 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,172.54 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 663.34 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 663.34 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,121.98 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,951.09 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 686.98 ms |
|
Code review by qodo was updated up to the latest commit 8dd1cfb |
jsr: package names (empty scope/name, path separators)jsr: and named-registry package names (empty scope/name, path separators)
|
Code review by qodo was updated up to the latest commit 85f2074 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 85f2074 |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier.rs`:
- Around line 268-280: The package-name validation in
is_well_formed_package_name still allows dot-segment names, which then reach
to_registry_url and can be normalized incorrectly in request URLs. Update this
validator to reject "." and ".." for both unscoped and scoped names, and add
regression coverage for gh:.. and gh:`@acme/`..; also apply the same dot-segment
guard in the TypeScript parser to keep both parsers consistent.
In `@pacquet/crates/resolving-npm-resolver/src/parse_bare_specifier/tests.rs`:
- Around line 381-413: The new regression tests in
named_registry_path_separators_in_name_error cover embedded traversal, but they
still miss bare "." and ".." package-name segments that should also be rejected.
Extend parse_bare_specifier tests by adding cases for inputs like gh:.., gh:.,
and gh:`@acme/`.. so parse_named_registry_specifier_to_registry_package_spec
returns InvalidPackageName for each. Keep the coverage alongside the existing
named_registry_empty_scope_errors and
named_registry_path_separators_in_name_error tests to ensure every rejected
shape is exercised.
In `@pnpm11/resolving/npm-resolver/src/parseBareSpecifier.ts`:
- Around line 172-182: Update the package-name validation so bare `.` and `..`
are rejected before they can flow into mirror path resolution. In
`isWellFormedPackageName` inside `parseBareSpecifier`, add explicit checks for
these dot-segment names and ensure scoped forms like `@scope/..` are also
rejected, then mirror the same guard in the pacquet resolver path that feeds
`getPkgMirrorPath`. Keep the fix localized to the package-name validation
helpers so all resolver entry points consistently block these names.
In `@pnpm11/resolving/npm-resolver/test/parseBareSpecifier.test.ts`:
- Around line 118-131: Add test coverage in parseBareSpecifier.test.ts for bare
"." and ".." segments such as gh:.. and gh:`@acme/`.., since
parseNamedRegistrySpecifierToRegistryPackageSpec currently has a validation gap
for these inputs. Extend the existing invalid-specifier tests alongside the
current path-separator cases so the same
ERR_PNPM_INVALID_NAMED_REGISTRY_PACKAGE_NAME expectation is asserted for these
new bare segment variants.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e7f6889f-b105-44bc-8ca0-958afd79328d
📒 Files selected for processing (5)
.changeset/named-registry-invalid-name.mdpacquet/crates/resolving-npm-resolver/src/parse_bare_specifier.rspacquet/crates/resolving-npm-resolver/src/parse_bare_specifier/tests.rspnpm11/resolving/npm-resolver/src/parseBareSpecifier.tspnpm11/resolving/npm-resolver/test/parseBareSpecifier.test.ts
✅ Files skipped from review due to trivial changes (1)
- .changeset/named-registry-invalid-name.md
'.' and '..' passed the separator checks but are never valid npm names, and as URL path segments they normalize away from the intended registry path. Reject them in both stacks.
|
Code review by qodo was updated up to the latest commit 0d12999 |
1 similar comment
|
Code review by qodo was updated up to the latest commit 0d12999 |
…pm-package-name Replace the hand-rolled shape checks in the jsr: and named-registry specifier parsers with the validator both stacks already ship: validate-npm-package-name (validForOldPackages) in TypeScript and its existing port is_valid_old_npm_package_name in pacquet. It covers the previously rejected shapes and everything else npm forbids (leading dots, non-URL-safe characters, node_modules, whitespace).
|
Code review by qodo was updated up to the latest commit 9a14025 |
|
Code review by qodo was updated up to the latest commit 9a14025 |
…tore upgrade Both DoS advisories are fixed only in quick-xml 0.41.0, which no object_store release can resolve yet (0.13 requires ^0.39, 0.14 requires ^0.40.1). The parsed XML comes only from the operator-configured S3 backend in pnpr, not from untrusted clients.
|
Code review by qodo was updated up to the latest commit 64a550a |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
Code review by qodo was updated up to the latest commit 64a550a |
Summary
jsrToNpmPackageNamechecked for a missing/separator but not for other malformed shapes. Passingjsr:@foo/(a scope with a trailing slash but no name) silently returned the malformed npm package name@jsr/foo__instead of raisingINVALID_JSR_PACKAGE_NAME. Review also surfaced that the name segment could carry extra path separators (e.g.jsr:@foo/../bar), which flowed into the generated@jsr/...npm name and from there into registry URLs and metadata cache file paths — a path-injection risk.The named-registry specifier parser (e.g.
gh:) had the same class of gap: its scoped branch only checked for a missing/and a trailing slash, and its unscoped branch checked nothing, so names likegh:@foo/../bar,gh:@/bar,gh:foo/../bar, dot segments (gh:..), and backslash variants parsed successfully. The downstreamvalidatePackageNamein pick-package only rejects a/in unscoped names, so scoped traversal reachedgetPkgMirrorPath, which joins the raw name into the metadata cache file path.Fix
Both parsers now validate the package name with the validator the repo already ships —
validate-npm-package-name(validForOldPackages) in TypeScript and its existing pacquet portis_valid_old_npm_package_name— instead of hand-rolled shape checks. That rejects every shape above (empty scope/name, extra/,\,./..) plus everything else npm forbids (leading dots/underscores/hyphens, non-URL-safe characters,node_modules, whitespace).jsrToNpmPackageNamethrowsINVALID_JSR_PACKAGE_NAMEfor any invalid scoped name (missing-scope input still throwsMISSING_JSR_PACKAGE_SCOPE).parseNamedRegistrySpecifierToRegistryPackageSpecvalidates all branches (scoped, unscoped, and alias-derived names) and throwsINVALID_NAMED_REGISTRY_PACKAGE_NAME— the error code its scoped branch already used.Both fixes land in the TypeScript CLI and pacquet, keeping the two stacks behaviorally identical.
Testing
pnpm --filter @pnpm/resolving.jsr-specifier-parser test— 8/8 pass (new cases for the rejected shapes).pnpm --filter @pnpm/resolving.npm-resolver test— 236/236 pass (new negative cases for named-registry names, incl. dot segments).cargo nextest run -p pacquet-resolving-jsr-specifier-parser -p pacquet-resolving-npm-resolver— 283/283 pass.cargo clippy --all-targets -- --deny warnings,cargo fmt --check, andtypos pacquet pnprclean.Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.