mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Fixes #23275 ### What does this PR do? This PR fixes a bug where `bunfig.toml` files starting with a UTF-8 BOM (byte order mark, `U+FEFF` or bytes `0xEF 0xBB 0xBF`) would fail to parse with an "Unexpected" error. The fix uses Bun's existing `File.toSource()` function with `convert_bom: true` option when loading config files. This properly detects and strips the BOM before parsing, matching the behavior of other file readers in Bun (like the JavaScript lexer which treats `0xFEFF` as whitespace). **Changes:** - Modified `src/cli/Arguments.zig` to use `bun.sys.File.toSource()` with BOM conversion instead of manually reading the file - Simplified the config loading code by removing intermediate file handle and buffer logic ### How did you verify your code works? Added comprehensive regression tests in `test/regression/issue/23275.test.ts` that verify: 1. ✅ `bunfig.toml` with UTF-8 BOM parses correctly without errors 2. ✅ `bunfig.toml` without BOM still works (regression test) 3. ✅ `bunfig.toml` with BOM and actual config content parses the content correctly All three tests pass with the debug build: ``` 3 pass 0 fail 11 expect() calls Ran 3 tests across 1 file. [6.41s] ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
45 lines
1.1 KiB
JSON
45 lines
1.1 KiB
JSON
{
|
|
" != undefined": 0,
|
|
" == undefined": 0,
|
|
" catch bun.outOfMemory()": 0,
|
|
"!= alloc.ptr": 0,
|
|
"!= allocator.ptr": 0,
|
|
".arguments_old(": 265,
|
|
".jsBoolean(false)": 0,
|
|
".jsBoolean(true)": 0,
|
|
".stdDir()": 41,
|
|
".stdFile()": 17,
|
|
"// autofix": 167,
|
|
": [^=]+= undefined,$": 256,
|
|
"== alloc.ptr": 0,
|
|
"== allocator.ptr": 0,
|
|
"@import(\"bun\").": 0,
|
|
"EXCEPTION_ASSERT(!scope.exception())": 0,
|
|
"JSValue.false": 0,
|
|
"JSValue.true": 0,
|
|
"alloc.ptr !=": 0,
|
|
"alloc.ptr ==": 0,
|
|
"allocator.ptr !=": 1,
|
|
"allocator.ptr ==": 0,
|
|
"global.hasException": 28,
|
|
"globalObject.hasException": 47,
|
|
"globalThis.hasException": 125,
|
|
"std.StringArrayHashMap(": 1,
|
|
"std.StringArrayHashMapUnmanaged(": 11,
|
|
"std.StringHashMap(": 0,
|
|
"std.StringHashMapUnmanaged(": 0,
|
|
"std.Thread.Mutex": 1,
|
|
"std.debug.assert": 26,
|
|
"std.debug.dumpStackTrace": 0,
|
|
"std.debug.print": 0,
|
|
"std.enums.tagName(": 2,
|
|
"std.fs.Dir": 168,
|
|
"std.fs.File": 62,
|
|
"std.fs.cwd": 104,
|
|
"std.log": 1,
|
|
"std.mem.indexOfAny(u8": 0,
|
|
"std.unicode": 27,
|
|
"undefined != ": 0,
|
|
"undefined == ": 0,
|
|
"usingnamespace": 0
|
|
} |