files-community / files-community/Files

Bug: Characters disallowed by `PathCleanupSpec` in filesystems mounted via WSL2 are rendered as invalid codepoints.

Open
#17,205 9 comments 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
45.4k
Forks
2.9k
Avg merge
19h 7m
Merged PRs (30d)
62

Description

### Description

I've some directories and files whose names are comprised of tabs (` `). Inside `dolphin-25.04.2-1.fc42` (on `cpe:/o:fedoraproject:fedora:42`), these render as expected:

![Image](https://github.com/user-attachments/assets/927e3da8-0d75-4d54-b75b-68f5825c423c)

However, in `FilesPreview`, these render as UTF tofu:

![Image](https://github.com/user-attachments/assets/e9e0713a-beb3-4d4c-a2a7-1ab0672189bb)

To confirm, if I duplicate one of their filenames to my Windows clipboard, I see:

> ```{title ,id s22ai3}`{.JSON5}.dir``

However, this should be, per my Linux installation:

> `` `{title: "", id: "s22ai3"}`{.JSON5}.dir``

...which can be confirmed with `tree` there:

~~~ini
.
└── \011`{title: "",\011id: "s22ai3"}`{.JSON5}.dir
~~~

This is a significant problem, because it means that Files is performing character replacement, thereby potentially making unintentionally modifying the filename trivial. I haven't confirmed this because I don't dare: I *should* have mounted this as `ro`.

Please note that although, in the browser, you're probably seeing [hexagana](https://english.stackexchange.com/revisions/352613/1#:~:text=Displaying%20the%20hex%20codes%20of,was%20referred%20to%20as%20%22hexagana%22.) if you're using Windows, this is font-dependent, so Files isn't doing anything special. It's merely not rendering the characters. As an example, ``explorer.exe "\\?\UNC\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\. [ ]`{title Git,id s2ykra}`{.JSON5}.dir"`` also fails to, but renders *another* (incorrect) replacement character:

![Image](https://github.com/user-attachments/assets/aba33b76-4950-4150-b8de-a4bb7941a1d9)

### Steps To Reproduce

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

### Files Version

3.9.10.0

### Windows Version

10.0.26120

### User ID

353b71b8-86f9-4fe0-ac0e-e1da114b9349

### Log File

[debug.log](https://github.com/user-attachments/files/20847639/debug.log)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.