Repository navigation
[repo-assist] Fix createRelativePath mangling paths with special characters (#, %, &) - #4359
Merged
dsyme merged 1 commit intoAug 26, 2026
Conversation
createRelativePath used Uri.MakeRelativeUri, which percent-encodes reserved characters such as #, %, and &. The previous code only undid the space encoding (%20), so file/directory names containing other special characters (e.g. some#file, some&file) were returned with escaped characters embedded in the path. Fix: unescape the entire relative URI string with Uri.UnescapeDataString instead of only replacing %20. Added tests covering #, %, and & characters in UtilsSpecs.fs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
marked this pull request as ready for review
August 26, 2026 18:44
This was referenced Oct 5, 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.
🤖 This PR was authored by Repo Assist, an automated AI assistant, as part of routine testing-improvement work on this repository.
Root cause
createRelativePath(insrc/Paket.Core/Common/Utils.fs) builds a relative path usingUri.MakeRelativeUri, which percent-encodes reserved/special characters in the resulting URI string (spaces,#,%,&, etc.). The existing code only reversed the space encoding (Replace("%20", " ")), so any file or directory name containing other special characters — most notably#— would come back with the escaped sequence baked into the path string (e.g.some#file→some%23file).This function is used throughout project-file and template-file writers (
ProjectFile.fs,InstallProcess.fs,NugetConvert.fs,LocalFile.fs,DependenciesFileParser.fs), so any file/folder name with such characters could end up with a mangled path written into a.csproj/.fsproj,paket.local, etc.Fix
Replaced the single
%20-specific replace withUri.UnescapeDataString(...), which unescapes all percent-encoded characters generically, not just spaces.Trade-offs
This is a minimal, surgical change to one small function.
Uri.UnescapeDataStringis part of the base class library and behaves as a strict superset of the previous%20-only replace, so all previously passing behavior (including the existing "handle spaces" test) is preserved.Tests
Added three new tests to
tests/Paket.Tests/UtilsSpecs.fscovering#,&, and%characters in relative paths, alongside the existing space-handling test.Test Status
dotnet build src/Paket.Core/Paket.Core.fsproj -f netstandard2.0— succeeded, 0 errors (11 pre-existing warnings unrelated to this change).dotnet test tests/Paket.Tests/Paket.Tests.fsproj -f net9 --filter "FullyQualifiedName~UtilsSpecs.createRelativePath"— 4/4 passed (1 existing + 3 new).dotnet test tests/Paket.Tests/Paket.Tests.fsproj -f net9 --filter "FullyQualifiedName~ParserSpecs|FullyQualifiedName~SaveSpecs"— 172/172 passed, no regressions.UtilsSpecsrun showed 4 pre-existing, unrelated failures (proxy env-var parsing tests that also fail onmainwithout this change) — not caused by this PR.Add this agentic workflow to your repo
To install this agentic workflow, run