Skip to content

fix(path): do not decode percent-encoding in raw filesystem paths#18412

Open
ernestodeoliveira wants to merge 1 commit intoanomalyco:devfrom
ernestodeoliveira:fix/percent-encoding-in-raw-paths-v2
Open

fix(path): do not decode percent-encoding in raw filesystem paths#18412
ernestodeoliveira wants to merge 1 commit intoanomalyco:devfrom
ernestodeoliveira:fix/percent-encoding-in-raw-paths-v2

Conversation

@ernestodeoliveira
Copy link
Copy Markdown

Issue for this PR

Closes #18285

Type of change

  • Bug fix

What does this PR do?

normalize() was calling decodeURIComponent() 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 decodeFilePath when the input is a file:// 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:

  • one that verifies literal %20 in a raw path is preserved
  • one that verifies %20 in a file:// URL is still decoded correctly

Both pass. Existing tests unchanged.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot handle escape sequence in path

1 participant