Skip to content

fs: accept all valid utf8 values in fast paths#62304

Open
wdskuki wants to merge 1 commit intonodejs:mainfrom
wdskuki:fix-utf8-fast-paths
Open

fs: accept all valid utf8 values in fast paths#62304
wdskuki wants to merge 1 commit intonodejs:mainfrom
wdskuki:fix-utf8-fast-paths

Conversation

@wdskuki
Copy link

@wdskuki wdskuki commented Mar 18, 2026

This PR fixes issue #49888 by accepting all valid UTF8 encoding variants (utf8, utf-8, UTF8, UTF-8) in fs.readFileSync and fs.writeFileSync fast paths.

Changes

  • Modified lib/fs.js to accept UTF8 and UTF-8 (uppercase) in addition to utf8 and utf-8
  • Added test case to verify the fix

Testing

  • Added test/parallel/test-fs-utf8-fast-path-casing.js

Fixes: #49888

Accept UTF8 and UTF-8 (uppercase) in fs.readFileSync and
fs.writeFileSync fast paths, in addition to utf8 and utf-8.

Fixes: nodejs#49888
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs: utf8 fast paths don't accept all valid utf8 values

2 participants