Repository navigation
fix: accept POSIX root URIs from WSL2 clients on a Windows server - #3380
jaeminbird wants to merge 4 commits into
Conversation
2bf4eb5 to
d8949e7
Compare
|
@Lightning00Blade can you PTAL since you previously reviewed #2840 ? Thanks! |
Lightning00Blade
left a comment
There was a problem hiding this comment.
- Manual check in WSL2. No automated test checks that path.resolve maps the POSIX root to \wsl.localhost<distro>... against a UNC working directory,
because that only happens on a real Windows host started from WSL. Could you confirm you ran the repro from the issue? That means a WSL2 client launching
Windows node.exe, then take_screenshot with filePath: "/home///shot.png", which should now succeed. - PR description. Please list both user-visible changes:
• file:// tool arguments without a drive letter (in ToolHandler.validateAndResolvePathOrUrl) are now read as POSIX paths on Windows. Before, they were
rejected.
• If the server's working directory is a normal drive rather than a UNC path, a POSIX root such as file:///home/user now resolves to :\home\user. Before, the root was dropped. This is rare, but worth stating.
|
@Lightning00Blade Ran the issue's repro on Windows 11 + WSL2 (Node 24.18, headless main (81a0379): This branch (a42fd23): Also checked the drive-cwd case: with cwd |
A WSL2 client that starts the server on the Windows side advertises roots like file:///home/user/project. fileURLToPath rejects those on Windows, so the roots were dropped and every path inside them was denied. Read file URLs with no host and no drive letter as POSIX paths; path.resolve then maps them onto the server's \\wsl.localhost working directory. Fixes ChromeDevTools#2839
a42fd23 to
bcf8561
Compare
A WSL2 client that launches the server on the Windows side advertises roots like
file:///home/user/project. On WindowsfileURLToPaththrowsFile URL path must be absolute, the root is dropped, and every path inside it is denied (#2839).New
fileUrlToPathWithPosixFallback()insrc/utils/files.tsreads a file URL with no host and no drive letter as POSIX;path.resolvethen maps it onto the server's\\wsl.localhost\<distro>cwd, the same canonical formvalidatePathgives the file. Drive-letter and UNC URLs are unchanged.User-visible changes on Windows:
file:///home/userresolves to<current drive>:\home\user.file:tool arguments without a drive letter (ToolHandler.validateAndResolvePathOrUrl) are read as POSIX paths instead of rejected.Validation (Windows 11, Node 24.18):
npm run testpasses except a symlink test (no privilege here); Linux (docker): new tests pass.node.exe,take_screenshotto/home/clab/cdm-wsl-test/shot.png. main denies it, this branch writes the file.Fixes #2839. Picks up #2840, closed for a missing CLA.