mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
## What does this PR do? Fixes #22003 by escaping tab characters in filenames when generating sourcemap JSON. When a filename contained a tab character (e.g., `file\ttab.js`), the sourcemap JSON would contain a **literal tab byte** instead of the escaped `\t`, producing invalid JSON that caused `error: InvalidSourceMap`. The root cause was in `src/bun.js/bindings/highway_strings.cpp` where the scalar fallback path had: ```cpp if (char_ >= 127 || (char_ < 0x20 && char_ != 0x09) || ...) ``` This **exempted tab characters** (0x09) from being detected as needing escape, while the SIMD path correctly detected them. The fix removes the `&& char_ != 0x09` exemption so both paths consistently escape tabs. ## How did you verify your code works? Added regression test in `test/regression/issue/22003.test.ts` that: - Creates a file with a tab character in its filename - Builds it with sourcemap generation - Verifies the sourcemap is valid JSON - Checks that the tab is escaped as `\t` (not a literal byte) The test **fails on system bun** (produces invalid JSON with literal tab): ```bash USE_SYSTEM_BUN=1 bun test test/regression/issue/22003.test.ts # error: JSON Parse error: Unterminated string ``` The test **passes with the fix** (tab properly escaped): ```bash bun bd test test/regression/issue/22003.test.ts # ✓ 1 pass ``` --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
1.2 KiB
1.2 KiB