fix: Decode percent-encoded image data URLs - #2617
Open
GtechGovind wants to merge 1 commit into
Open
Conversation
GtechGovind
marked this pull request as ready for review
August 28, 2026 06:09
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.
Fixes #2126.
I added percent-decoding for image data-URL payloads so encoded SVGs and binary images load correctly. Decoding works on bytes rather than using
decodeURIComponent, which rejects valid non-UTF-8 image bytes and literal percentages in SVGs.%xxescapes once, preserving raw UTF-8, plus signs, and malformed escape sequences.Validation on macOS Apple Silicon:
zig build -j4with Zig 0.16.0: passed.npm test -- --reporter doton Node 24.19.0: 325 passed, six existing pending tests.node node_modules/mocha/bin/mocha.js --reporter dot 'test/*.test.js'on Node 26.0.0: 325 passed, six existing pending tests.npm run lint,npm run tsd, and targeted Standard checks for the new decoder/test files: passed.Unsupported image typebefore the implementation and pass afterward.fetch(dataURL)byte output, covering UTF-8, binary bytes, plus signs, literal percentages, and partial/invalid escapes.Linux/Windows and the generated WPT suite were not run locally. This change does not attempt to overhaul existing data-URL metadata parsing or base64 validation.