Repository navigation
fix(core): reject relative path segments in repository hosts - #51577
Merged
Merged
Conversation
Repository.cachePath turns each `:`-separated part of a reference host into a directory under the repos cache root. The host check only rejected whitespace, slashes and a leading dash, so hosts such as `..` (from `..:name`, `ssh://../repo` or `https://%2e%2e/...`) produced a cache path one level above the root. RepositoryCache.ensure then recursively removed that path when it was not a matching checkout, so a `references` entry in project config could delete data next to the cache on refresh. Validate every host part with the same rule already used for path segments, so such references are rejected at parse time and never reach the cache.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
nexxeln
approved these changes
Sep 28, 2026
This was referenced Oct 15, 2026
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.
Issue for this PR
Closes #51576
Type of change
What does this PR do?
Repository.cachePathturns each:-separated host part into a directory.safeHostdidn't reject.or.., so a reference like..:docsgot a cache path outside the repos cache root.RepositoryCache.ensurethen deleted that path, because it wasn't a matching checkout.This change checks every host part with the existing
safeSegmentrule, the same rule already used for path segments. These references now fail inparseRemote, andReferencenever hands them to the cache. Valid hosts, including ones with a port, parse the same as before.How did you verify your code works?
repository.test.ts. The new host cases fail without the fix and pass with it. Another test checks that a host with a port keeps its cache path.RepositoryCachebefore the fix, and it no longer happens after.bun testandbun typecheckinpackages/core. The suite shows the same pre-existing failures before and after; those tests need network access.Screenshots / recordings
N/A, not a UI change.
Checklist