[Bug] Characters in paths permitted by Linux (usable via BTRFS) that aren't permitted by `PathCleanupSpec` become `$Null` or invalid codepoints.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Windows Version
10.0.26120.0
### WSL Version
2.6.0.0
### Are you using WSL 1 or WSL 2?
1. [x] WSL 2
1. [ ] WSL 1
### Kernel Version
> `uname -a`
`uname -a` returns:
> Linux version `6.6.87.2-microsoft-standard-WSL2` (`root@439a258ad544`) (`gcc` (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP `PREEMPT_DYNAMIC` Thu Jun 5 18:30:46 UTC 2025
### Distro Version
> `lsb-release`
LSB has been long deprecated, so it isn't available outside of Debian derivatives. Consequently, `etc/os-release` returns `cpe:/o:fedoraproject:fedora:39` and `HOME_URL="https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL"`.
### Other Software
https://github.com/microsoft/terminal/issues/19058#issue-3165296987 includes this information (from an unrelated BR about `MAX_PATH`):
1. Obviously, `explorer.exe` applies:
1. ~~~pwsh
#!/usr/bin/env pwsh
#Requires -PSEdition 'Core'
If ($IsWindows)
{
Get-Item -Path (
Get-Command 'explorer' | `
Select-Object -ExpandProperty 'Source'
) | `
Select-Object -ExpandProperty 'VersionInfo' | `
Format-List
}
~~~[^1]
[^1]: [`stackoverflow.com/revisions/45517267/4`][1]
[1]: https://stackoverflow.com/revisions/45517267/4#:~:text=(Get%2DItem%20%2DPath%20'C:%5CProgram%20Files%5CJava%5Cjdk1.8.0_144%5Cbin%5Cjava.exe').VersionInfo%20%7C,Format%2DList%20%2DForce
1.
~~~YAML
OriginalFilename : EXPLORER.EXE.MUI
FileDescription : Windows Explorer
ProductName : Microsoft® Windows® Operating System
Comments :
CompanyName : Microsoft Corporation
FileName : C:\Windows\explorer.exe
FileVersion : 10.0.26100.4441 (WinBuild.160101.0800)
ProductVersion : 10.0.26100.4441
IsDebug : False
IsPatched : False
IsPreRelease : False
IsPrivateBuild : False
IsSpecialBuild : False
Language : English (United Kingdom)
LegalCopyright : © Microsoft Corporation. All rights reserved.
LegalTrademarks :
PrivateBuild :
SpecialBuild :
FileVersionRaw : 10.0.26100.2415
ProductVersionRaw : 10.0.26100.2415
~~~
1. However, https://github.com/files-community/Files/issues/17133#issuecomment-2993670910 could also apply here:
1. ~~~pwsh
#!/usr/bin/env pwsh
Get-AppxPackage FilesPreview
~~~1.
~~~YAML
Publisher : CN=Yair Aichenbaum, O=Yair Aichenbaum, L=Baltimore, S=Maryland, C=US
ResourceId :
InstallLocation : C:\Program Files\WindowsApps\FilesPreview_3.9.10.0_x64__1y0xx7n9077q4
IsFramework : False
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
Dependencies : {Microsoft.WindowsAppRuntime.1.7_7000.522.1444.0_x64__8wekyb3d8bbwe,
Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64__8wekyb3d8bbwe,
Microsoft.VCLibs.140.00_14.0.33519.0_x64__8wekyb3d8bbwe}
IsPartiallyStaged : False
SignatureKind : Developer
Status : Ok
~~~
### Repro Steps
As https://github.com/files-community/Files/issues/17205#issue-3165260231 explains:
1. Using a real Linux OS, in a BTRFS filesystem, create a path longer than `MAX_PATH` that contains tab characters.
1. Install the `.MSIXBundle` from [`WhitewaterFoundry/Fedora-Remix-for-WSL/releases/tag/42.0.5`](https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL/releases/tag/42.0.5):
~~~pwsh
#!/usr/bin/env pwsh
#Requires -PSEdition Core
#Requires -Version 7.6
If ($IsWindows) { Add-AppxPackage -Path "$LocationToMSIX" } # Usually, `$Env:UserProfile/Downloads`.
~~~1. On the host, execute the undermentioned:
~~~pwsh
#!/usr/bin/env pwsh
#Requires -PSEdition Core
If ($IsWindows) { wmic diskdrive list brief }
~~~[^wmic]
[^wmic]: [`blog.bryanroessler.com/2020-12-14-btrfs-on-wsl2/`][wmic]
[wmic]: https://blog.bryanroessler.com/2020-12-14-btrfs-on-wsl2/#:~:text=wmic%20diskdrive%20list%20brief
1. When the correct filesystem has been identified:
~~~pwsh
#!/usr/bin/env pwsh
#Requires -PSEdition Core
If ($IsWindows) { sudo wsl --mount \\.\PHYSICALDRIVE1 --bare }
~~~1. Likewise, on WSL:
~~~sh
#!/usr/bin/env sh
sudo lsblk -o NAME,FSTYPE,FSVER,FSAVAIL,MOUNTPOINTS
~~~This shall return output similar to the undermentioned:
~~~RS
NAME FSTYPE FSVER FSAVAIL MOUNTPOINTS
sda ext4 1.0
sdb ext4 1.0
sdc swap 1 [SWAP]
sdd ext4 1.0 954.6G /mnt/wslg/distro
/
sde
├─sde1 vfat FAT32
├─sde2 ext4 1.0
├─sde3 ext4 1.0
└─sde4 btrfs 1.2T /mnt/rjlb/fedora
~~~
Utilise the output to confirm that the *device* has been mounted into `wsl`, then set its path as `$dev_id`, and define a mount point at `$path`.
1. When the correct filesystem has been identified:
~~~sh
#!/usr/bin/env sh
sudo mkdir /mnt/$path && \
sudo mount -t btrfs -o ro /dev/$dev_id /mnt/$path
~~~[^ro]
[^ro]: [`askubuntu.com/revisions/296342/3`][ro]
[ro]: https://askubuntu.com/revisions/296342/3#content:~:text=sudo%20mount-,%2Do%20ro,-/dev/sda1%20/media/2tb
### Expected Behavior
Consumers should be provided with escaped or verbatim representations of the file paths.
### Actual Behavior
Most importantly, `explorer.exe` (and others, like `FilesCommunity.Files`, hence the report *here*, rather than at Feedback Hub) render replacement characters for invalid codepoints where the tabs should be. WSL shouldn't ever *replace* valid UTF codepoints with invalid codepoints. UNICODE doesn't *ever* permit that.
Additionally, IDK whether it's due to being past `MAX_PATH` or the filenames themselves, but if I open a `wt.exe` instance (via `FilesPreview`, because of https://github.com/microsoft/terminal/issues/19058#issue-3165296987) at `Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\fedoraremix\mnt\rjlb_data\@{'Name'='Entities'}#.dir\@{'Status'='Commenced'; 'Name'='In Use'}#.dir\@{'Person'='Beedell'; 'Identifier'='S21AIB'}#.dir\@{'Name'='Entity-Specific'}#.dir\@{'Person'='Roke'; 'Identifier'='S1EV2L'}#.dir\@{'Name'='Temporary'}#.dir`, then run:
1. `tree` spawns in a new `OpenConsole` window (which it never does elsewhere), then crashes (per WinDbg):
~~~YAML
C:\__w\1\s\src\server\ConDrvDeviceComm.cpp(147)\OpenConsole.exe!00007FF7CF792894: (caller: 00007FF7CF7925C7) ReturnHr(1) tid(6020) 800700E9 No process is on the other end of the pipe.
ntdll!NtTerminateProcess+0x14:
00007ffc`1f7dfc34 c3 ret
0:007> k
# Child-SP RetAddr Call Site
00 0000002b`3a7ffc38 00007ffc`1f75fd8e ntdll!NtTerminateProcess+0x14
01 0000002b`3a7ffc40 00007ffc`1e9218ab ntdll!RtlExitUserProcess+0x11e
02 0000002b`3a7ffc70 00007ff7`cf70a4b9 KERNEL32!ExitProcessImplementation+0xb
03 0000002b`3a7ffca0 00007ff7`cf72eb47 OpenConsole+0xa4b9
04 0000002b`3a7ffcd0 00007ffc`1e90e8d7 OpenConsole+0x2eb47
05 0000002b`3a7fff50 00007ffc`1f75fbcc KERNEL32!BaseThreadInitThunk+0x17
06 0000002b`3a7fff80 00000000`00000000 ntdll!RtlUserThreadStart+0x2c
~~~
Originally, I thought it was designed to close on completion, but `tree`, in all other circumstances, doesn't spawn a new window. It wouldn't make much sense for a standalone window, anyway. (I've a `.dump /ma`, if of use, although IDK whether that would probably be best provided to the Windows Terminal team.)
1. Per https://github.com/PowerShell/PowerShell/issues/25680#issue-3165895356, `Get-ChildItem`, no names are returned, despite Windows disallowing `$Null` filenames:
~~~MA
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\fedoraremix\mnt\rjlb_data\@{'Name'='Entities'}#.dir\@{'Status'='Commenced'; 'Name'='In Use'}#.dir\@{'Person'='Beedell'; 'Identifier'='S21AIB'}#.dir\@{'Name'='Entity-Specific'}#.dir\@{'Person'='Roke'; 'Identifier'='S1EV2L'}#.dir\@{'Name'='Temporary'}#.dir> lsDirectory: \\wsl.localhost\fedoraremix\mnt\rjlb_data\@{'Name'='Entities'}#.dir\@{'Status'='Commenced'; 'Name'='In
Use'}#.dir\@{'Person'='Beedell'; 'Identifier'='S21AIB'}#.dir\@{'Name'='Entity-Specific'}#.dir\@{'Person'='Roke';
'Identifier'='S1EV2L'}#.dir\@{'Name'='Temporary'}#.dirMode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024-04-08 13:30
d---- 2023-09-25 23:51
d---- 2023-03-21 16:30
d---- 2023-12-16 03:10
d---- 2023-04-15 19:55
d---- 2022-10-23 22:23
d---- 2023-09-22 22:00
d---- 2023-09-22 22:01
----- 2022-06-23 14:26 1011594814
----- 2022-05-12 23:15 144430
----- 2022-07-01 00:20 557
----- 2022-01-07 00:50 373962
----- 2023-09-22 22:02 67
----- 2021-03-19 14:41 65647 @{'Status'='Completed'; 'Name'='Instagram Illustration';
'Identifier'='S1G0ZM'}#.JPEG
----- 2022-05-12 23:15 3296
----- 2022-05-26 13:21 440127
----- 2022-05-26 13:25 18313
----- 2022-06-30 09:13 141148
----- 2022-06-30 09:14 250847
----- 2022-07-01 17:35 35892
----- 2022-07-02 01:14 165810
----- 2022-07-02 01:14 48157
----- 2022-07-03 14:10 376541
----- 2021-12-24 15:18 9367
----- 2022-03-23 14:59 25051
----- 2023-07-04 23:41 34374
~~~
Heck, I shan't be surprised if this relates to https://github.com/microsoft/WinDbg-Feedback/issues/248#issuecomment-2508995080 too.
### Diagnostic Logs
I've attempted to adhere to [`github.com/microsoft/WSL/blob/769e508a341ad45dd24ee0794e75a15a6d211986/CONTRIBUTING.md?plain=1#L104C1-L112C65`](https://github.com/microsoft/WSL/blob/769e508a341ad45dd24ee0794e75a15a6d211986/CONTRIBUTING.md?plain=1#L104C1-L112C65:~:text=To%20collect%20dumps%20of%20all,file%20when%20it%20is%20done.), but it merely hangs:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.