Skip to content

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

Closed
mortezashojaei wants to merge 1 commit into
wevm:mainfrom
mortezashojaei:fix/preserve-leading-feff
Closed

mortezashojaei wants to merge 1 commit into
wevm:mainfrom
mortezashojaei:fix/preserve-leading-feff

Conversation

@mortezashojaei

Copy link
Copy Markdown
Contributor

Decoding UTF-8 beginning with ef bb bf currently drops the first U+FEFF: hexToString('0xefbbbf68656c6c6f') returns 'hello' instead of '\uFEFFhello'. ABI string round trips lose the same character.

Configure the three lazy, reused decoders in decodeAbiParameters, hexToString, and bytesToString with ignoreBOM: true. This preserves U+FEFF as string content without changing padding, size checks, or malformed-UTF-8 replacement. Includes colocated regressions and a patch changeset. #4844 is a related data-preservation precedent with a different cause.

Validation against main 4febd2254b53b9ebd692b1c7ed38e42558d3489c:

  • Three affected test files, using an external Vitest 5.1.1 config on Node 24.22.3: 12 failed / 126 passed before; 138 passed after. Covers lone, leading, repeated, and interior U+FEFF, nested ABI strings, repeated calls, delegation, and sized decoding.
  • Removing each decoder correction separately produces 4 failures in its corresponding test file.
  • tsc -p src/tsconfig.json (TypeScript 7.0.2), Biome 2.2.4 check on all six changed TypeScript files, and git diff --check: passed.
  • Broader ABI/encoding harness: 575 passed; three suites cannot load missing fast-check/prool, and one RPC-dependent test times out. The same four failures reproduce on unchanged source.

Draft pending normal workspace validation: the pinned pnpm 12.16.1 is unavailable from the registry. With the fallback harness, the repository test script cannot load prool, and pnpm check:types is blocked by missing workspace dependencies (including Bun types and Vocs). The external config uses source aliases and error formatting setup, without blockchain setup; these results do not establish full CI success. Package metadata and the lockfile are unchanged.

Compatibility: callers that relied on stripping an initial U+FEFF will now receive that character.

@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a7d5c8d

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

@mortezashojaei
mortezashojaei marked this pull request as ready for review November 18, 2026 21:27

jxom commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thanks @mortezashojaei, this is a real data-loss fix! I've carried your commit forward in #5590 with small test and changeset follow-ups, so I'm closing this in favor of it.

@jxom jxom closed this Nov 18, 2026
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.

2 participants