fs.globSync returns incorrect results with non-UTF8 encoded file names.
Open
Nobody has claimed this yet.
confirmed-bug
fs
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
For example... on Linux, where file names are just byte sequences...
const { writeFileSync, existsSync, globSync } = require('node:fs');
const path = Buffer.from([0xe9]);
writeFileSync(path, 'hello');
existsSync(path); // true
console.log(globSync('[^a-z]')); // [ '�' ] non-utf8 bytes in the file name end up replaced.
The globSync, et. al APIs likely need an encoding option that instructs it to return the filenames as Buffer objects.
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.
Research direction
Start with the fs.globSync entry point and reproduce the Linux example using a filename containing the byte 0xe9. Trace how glob results are decoded and check the related glob APIs for consistent behavior. Done means non-UTF8 filenames can be returned without replacement characters, with the proposed Buffer-oriented encoding option covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100