fix(ext/fs): surface non-UTF-8 file names from read_dir (#34623)
## Summary `read_dir` in `ext/fs/std_fs.rs` previously dropped any directory entry whose name was not valid UTF-8 (`OsString::into_string().ok()?`). That silent filter made files with non-UTF-8 names invisible to `node:fs.globSync`, `node:fs.readdirSync`, and `Deno.readDirSync` — so the bug report at #30873 (`fs.globSync returns incorrect results with non-UTF8 encoded file names`) was actually two problems stacked: 1. The file existed on disk, but `read_dir` silently skipped it. 2. The user's own `writeFileSync(Buffer.from([0xe9]), 'hello')` lossily encoded the Buffer path to `�` (UTF-8 `EF BF BD`) before reaching the open syscall, so the file that *did* show up was actually a different, valid-UTF-8-named file. This PR fixes problem (1). Switching to `to_string_lossy().into_owned()` keeps the entry in the listing, with invalid byte sequences replaced by U+FFFD — matching Node's default `utf8` readdir behavior. (Lossless Buffer-path support throughout the fs ops is a larger refactor, separate from this regression.) ## Test plan - [x] Added regression test `[node/fs globSync] surfaces files with non-UTF-8 names` (Linux only — macOS/Windows reject or normalize non-UTF-8 names at the filesystem layer). The fixture is built via `bash + printf` so the raw `0xE9` byte reaches the kernel unmolested. - [ ] CI green on Linux/macOS/Windows. Closes denoland/divybot#376 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
E
em committed
49a1c401e0b90d6ea1483948334dbd91da8c9a14
Parent: 697bdb1
Committed by GitHub <noreply@github.com>
on 6/1/2026, 1:24:13 AM