Skip to content

fs.globSync returns incorrect results with non-UTF8 encoded file names. #59202

@jasnell

Description

@jasnell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions