Repository navigation
fix(browser): accept HAR files that begin with a byte-order mark - #1509
Merged
Merged
Conversation
HAR 1.2 lets writers emit a UTF-8 byte-order mark and requires readers to ignore it. The decoder passed ignoreBOM: true to TextDecoder, which keeps the mark in the decoded text, so a BOM-prefixed export failed as "HAR is malformed JSON." Decoding now uses the default, which skips one leading mark. The artifact digest still covers the selected file bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 2026
…luto#1509) HAR 1.2 lets writers emit a UTF-8 byte-order mark and requires readers to ignore it. The decoder passed ignoreBOM: true to TextDecoder, which keeps the mark in the decoded text, so a BOM-prefixed export failed as "HAR is malformed JSON." Decoding now uses the default, which skips one leading mark. The artifact digest still covers the selected file bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
inspect_web_network_capturerejected any HAR file that starts with a UTF-8 byte-order mark:The HAR 1.2 specification's encoding section says the file must be UTF-8, that the reader must ignore a byte-order mark if one exists, and that the writer may emit one. Some HAR writers do emit it.
The cause is a WHATWG naming trap in
HarCaptureProcess.ts:ignoreBOM: truemeans "do not treat the BOM specially", so it stays in the output ("{…}") andjsonc-parserthen reports malformed JSON. The default (ignoreBOM: false) skips one leading mark.Change
decodeHarText(bytes)inHarCapture.tsdecodes strict UTF-8 with the default BOM handling and keeps the existingHAR is not valid UTF-8 JSON.failure.HarCaptureProcessuses it.Verification
src/browser/history/HarCapture.test.tscovers four cases: a BOM-prefixed fixture decodes to the same capture as the plain one, a double BOM is still malformed, and invalid UTF-8 still fails. It fails onmainat the first assertion.npx vitest run src/browser/historypasses (61 tests).npm run test:focused -- tests/boundary/browser/historicalCaptureDecoder.test.ts tests/boundary/mcp/webNetworkCaptureMcp.test.ts tests/acceptance/tools/historicalCaptureResources.test.ts src/browser/history/CaptureFailures.test.tspasses (28 tests).npm run check:fastandnpm run docs:checkpass.🤖 Generated with Claude Code