Skip to content

fix: flatten path separators in pack output filename#9446

Merged
owlstronaut merged 1 commit into
npm:latestfrom
rootvector2:flatten-pack-filename-separators
Jun 2, 2026
Merged

fix: flatten path separators in pack output filename#9446
owlstronaut merged 1 commit into
npm:latestfrom
rootvector2:flatten-pack-filename-separators

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

npm pack writes the tarball to a name built from manifest.name with a non-global .replace(/\//, '-'), which only strips the single scope slash. When packing a remote tarball, git, or directory spec the name comes from a package.json that the registry never validated, so a name like x/../../../escaped keeps its ../ segments and path.resolve(packDestination, filename) lands the tarball outside the destination. Make the separator replacement global so the filename is always one path component.

@rootvector2 rootvector2 requested review from a team as code owners June 1, 2026 07:37
@owlstronaut owlstronaut changed the title flatten path separators in pack output filename fix: flatten path separators in pack output filename Jun 2, 2026
@owlstronaut owlstronaut merged commit 76f8059 into npm:latest Jun 2, 2026
18 of 19 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

🎉 Backport to release/v11 created: #9468

owlstronaut pushed a commit that referenced this pull request Jun 2, 2026
Backport of #9446 to `release/v11`.

Co-authored-by: Dexter.k <164054284+rootvector2@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants