Skip to content

Commit ed92374

Browse files
fix(desktop): keep WSL distros whose names start or end with a dot or hyphen
The distro name check required a letter, digit or underscore at both ends, but WSL registers names like "Ubuntu-" or ".Ubuntu". Selecting one in settings fell back to the default distro, and UNC paths inside it were not mapped. Allow dot and hyphen at either end, still rejecting "." and ".." so the UNC distro segment cannot be a relative path segment. Fixes #35955 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3ad5402 commit ed92374

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎apps/desktop/src/wsl/wslPathParsing.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ describe("wslUncPathToLinuxPath", () => {
8585

8686
it("rejects invalid distro names and non-WSL paths", () => {
8787
expect(wslUncPathToLinuxPath("\\\\wsl.localhost\\bad!name\\home")).toBeNull();
88+
expect(wslUncPathToLinuxPath("\\\\wsl.localhost\\..\\home")).toBeNull();
8889
expect(wslUncPathToLinuxPath("C:\\Users\\Josh\\repo")).toBeNull();
8990
});
9091
});

‎apps/desktop/src/wsl/wslPathParsing.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export interface WslConfig {
99
}
1010

1111
// Literal spaces only; \s would accept controls and corrupt UNC distro paths.
12-
const DISTRO_NAME_PATTERN = /^\w(?:[\w \-.]*\w)?$/;
12+
// "." and ".." would be path segments in a UNC path, not distro names.
13+
const DISTRO_NAME_PATTERN = /^(?!\.{1,2}$)[\w.-](?:[\w .-]*[\w.-])?$/;
1314

1415
export function parseWslDistroList(stdout: Buffer): readonly WslDistro[] {
1516
const hasUtf16Bom = stdout.length >= 2 && stdout[0] === 0xff && stdout[1] === 0xfe;

0 commit comments

Comments
 (0)