Skip to content

fix: preserve leading U+FEFF when decoding strings - #5590

Merged
jxom merged 3 commits into
mainfrom
fix/preserve-leading-feff
Nov 18, 2026
Merged

jxom merged 3 commits into
mainfrom
fix/preserve-leading-feff

Conversation

@jxom

@jxom jxom commented Nov 18, 2026

Copy link
Copy Markdown
Member

Supersedes #5589 by @mortezashojaei, keeping their commit and adding review follow-ups.

decodeAbiParameters, hexToString, and bytesToString decoded UTF-8 with a default TextDecoder, which strips one leading U+FEFF. A string that starts with ef bb bf lost that character, so ABI and hex round trips were lossy (hexToString('0xefbbbf68656c6c6f') returned 'hello'). The reused decoders now pass ignoreBOM: true.

  • Compatibility: ethers v6 (toUtf8String and AbiCoder.decode) and Solidity preserve the character. ox 0.14.67 (Hex.toString, Bytes.toString, AbiParameters.decode) still strips it, so simulateCalls asset symbol decoding (via ox AbiFunction.decodeResult) keeps the old behavior until ox changes.
  • Unchanged: the streaming HTTP and NDJSON body decoders still strip a BOM, matching Response.text().
  • Performance: Node keeps its UTF-8 fast path with ignoreBOM; a micro-benchmark showed no difference for 12 to 256 byte inputs.

Follow-ups on top of #5589:

  • Folded the regressions into the existing string cases (one leading-U+FEFF input each) instead of new test.each blocks. Dropped interior-U+FEFF cases that already passed on main and repeated-call assertions. The new assertions use toBe('\uFEFF…') because an inline snapshot renders U+FEFF invisibly.
  • Named the affected APIs in the changeset.

Checks: the three touched test files fail on the old decoders (3 failures) and pass with the fix (123 passed); Biome and tsc -p src/tsconfig.json pass.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Error Error Nov 18, 2026 9:30pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T21:28:27.370240Z 7f96122 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7f96122

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jxom
jxom merged commit 66b6f1f into main Nov 18, 2026
39 of 40 checks passed
@jxom
jxom deleted the fix/preserve-leading-feff branch November 18, 2026 21:35
@github-actions github-actions Bot mentioned this pull request Nov 18, 2026
jxom added a commit to wevm/ox that referenced this pull request Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#729)

- Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590).
- Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572).
- Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631).
- Added blockAccessListHash and slotNumber to Block (wevm/viem#5674).
- Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635).

Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e

Co-authored-by: Amp <[email protected]>
jxom added a commit to wevm/ox that referenced this pull request Nov 28, 2026
…e`, `Hex` and `PersonalMessage` (#730)

- Kept a leading U+FEFF when decoding UTF-8 strings (wevm/viem#5590).
- Rejected a missing static head after a dynamic parameter in AbiParameters.decode (wevm/viem#5572).
- Rejected odd-length hex in PersonalMessage.encode (wevm/viem#5631).
- Added blockAccessListHash and slotNumber to Block (wevm/viem#5674).
- Added baseFeePerBlobGas and blobGasUsedRatio to Fee.FeeHistory (wevm/viem#5635).

Backport of #729.

Amp-Thread-ID: https://ampcode.com/threads/T-01a21f59-905f-745c-8634-6581aa9f965e

Co-authored-by: Amp <[email protected]>

This branch had an error being deployed

1 failed deployment
Preview — 7f961224 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants