Skip to content

fix: prevent Linux paths from being converted to Windows drive paths#3642

Closed
xr843 wants to merge 1 commit intomodelcontextprotocol:mainfrom
xr843:fix/3628-linux-path-conversion
Closed

fix: prevent Linux paths from being converted to Windows drive paths#3642
xr843 wants to merge 1 commit intomodelcontextprotocol:mainfrom
xr843:fix/3628-linux-path-conversion

Conversation

@xr843
Copy link

@xr843 xr843 commented Mar 19, 2026

Summary

Fixes #3628

  • Added process.platform === 'win32' guards to Windows drive letter detection in convertToWindowsPath() and normalizePath() in path-utils.ts
  • Without these guards, paths like /h/username/data on Linux Docker containers are incorrectly matched by the ^[a-zA-Z]: regex after path.normalize() processing, and converted to Windows-style paths (H:\username\data)
  • Added tests reproducing the exact scenario from issue Docker Image 1.0.2 Breaks Linux Users with Letter at Start of Path #3628 (Linux Docker container with paths starting with a single letter directory)

Root cause

The convertToWindowsPath() function had a ^[a-zA-Z]: regex check (line 26) that converted forward slashes to backslashes for any path starting with a drive letter pattern, regardless of platform. Similarly, normalizePath() had a ^[a-zA-Z]: check (line 95) that applied Windows-specific formatting on all platforms. Both now only trigger when process.platform === 'win32'.

Test plan

  • All 149 existing filesystem tests pass
  • Added test: /h/username/data is preserved as-is on Linux
  • Added test: /h/username/MCP_Development/data (exact issue scenario) is preserved
  • Added test: convertToWindowsPath only converts C:/ style paths on Windows
  • Verified WSL path handling is unaffected

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

…3628)

Add process.platform === 'win32' guards to the Windows drive letter
detection in both convertToWindowsPath() and normalizePath(). Without
these guards, paths like /h/username/data on Linux Docker containers
could be incorrectly matched by the ^[a-zA-Z]: regex and converted to
Windows-style paths (H:\username\data).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xr843 xr843 closed this by deleting the head repository Mar 19, 2026
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.

Docker Image 1.0.2 Breaks Linux Users with Letter at Start of Path

1 participant