Repository navigation
fix: encode inline SVG avatars as UTF-8 in getEnsAvatar - #5250
Conversation
|
@RaphaelFakhri is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks, looks good. One regression: Suggested fix in Base64.toString(
resolvedNftUri
.replace('data:application/json;base64,', '')
.replace(/\s/g, ''),
)Plus a fixture token returning the token 109 payload with a newline in the middle and at the end, with the same expected snapshot. Generated by Claude Code |
|
Thanks for catching this. The latest push strips whitespace before decoding and adds a token 111 fixture with a newline in the middle and at the end. It expects the same snapshot as token 109. |
🦋 Changeset detectedLatest commit: 4799112 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
resolveAvatarUriencodes inline SVG avatars withbtoa, which throwsInvalidCharacterErrorfor any character outside Latin-1. As a result,getEnsAvatarreturnsnullfor SVG avatars that contain text likeéor emoji, including ERC-721 metadata whoseimage_datais an inline SVG.Fixes #5249
Changes
Base64.fromStringfrom ox, which encodes the UTF-8 bytes.data:application/json;base64,NFT metadata withBase64.toStringinstead ofatob.atobreturns Latin-1, which only worked before becausebtoare-encoded the same bytes. With a UTF-8 encoder, keepingatobwould double-encode non-ASCII metadata.Tests
resolveAvatarUri: inline SVG withcafé ⚡. Fails onmainwithInvalid character.parseAvatarRecord: ERC-721tokenURIas raw JSON with a UTF-8image_dataSVG (token 110 inEnsAvatarTokenUri). Fails onmainwithInvalid character.parseAvatarRecord: the same metadata as base64 JSON (token 109). Passes onmainand guards the decoder change; it fails if only the encoder is changed.