fix(path): do not decode percent-encoding in raw filesystem paths#18412
Open
ernestodeoliveira wants to merge 1 commit intoanomalyco:devfrom
Open
fix(path): do not decode percent-encoding in raw filesystem paths#18412ernestodeoliveira wants to merge 1 commit intoanomalyco:devfrom
ernestodeoliveira wants to merge 1 commit intoanomalyco:devfrom
Conversation
When a project path contains a literal percent-encoded sequence in the directory name (e.g. D:\First%20Second), normalize() was calling decodeURIComponent() unconditionally, silently converting the literal %20 to a space and resolving a different — non-existent — directory. Fix: apply decodeFilePath only when the input is a file:// URL. Raw filesystem paths (Windows or Unix) may contain literal % characters that are part of the folder/file name and must not be decoded. Adds regression tests for both the preserved-literal case and the expected decode-on-file-url case. Fixes anomalyco#18285
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 #18285
Type of change
What does this PR do?
normalize()was callingdecodeURIComponent()on all paths unconditionally. If a directory name contains a literal%20(e.g.D:\First%20Second), the function silently converts it to a space and resolves a path that doesn't exist.The fix is simple: only call
decodeFilePathwhen the input is afile://URL. Raw filesystem paths (Windows or Unix) may contain literal%characters that are part of the name and must not be decoded.How did you verify your code works?
Added two regression tests:
%20in a raw path is preserved%20in afile://URL is still decoded correctlyBoth pass. Existing tests unchanged.
Screenshots / recordings
N/A — no UI changes.
Checklist