fix: prevent Linux paths from being converted to Windows drive paths#3642
Closed
xr843 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
fix: prevent Linux paths from being converted to Windows drive paths#3642xr843 wants to merge 1 commit intomodelcontextprotocol:mainfrom
xr843 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
…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>
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.
Summary
Fixes #3628
process.platform === 'win32'guards to Windows drive letter detection inconvertToWindowsPath()andnormalizePath()inpath-utils.ts/h/username/dataon Linux Docker containers are incorrectly matched by the^[a-zA-Z]:regex afterpath.normalize()processing, and converted to Windows-style paths (H:\username\data)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 whenprocess.platform === 'win32'.Test plan
/h/username/datais preserved as-is on Linux/h/username/MCP_Development/data(exact issue scenario) is preservedconvertToWindowsPathonly convertsC:/style paths on Windows🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com