Repository navigation
Python: Decode percent-encoded base64 data URI payloads - #9664
Zhang Bowen (MuonChaser) wants to merge 1 commit into
Conversation
|
@microsoft-github-policy-service agree |
BlueRaddish
left a comment
There was a problem hiding this comment.
Independent offline verification of 532e37bc2932764c303f0ac335d1ec1744f99151 adds serialized-message coverage beyond the PNG cases: Linux / CPython 3.11 job.
I exercised public Content.from_uri() → Message.to_dict() → ordinary JSON encode/decode → Message.from_dict(), then public media detection and the existing binary extraction helpers. Across PNG, JPEG, GIF and PDF, both fully percent-escaped and mixed literal/escaped payloads preserve the original URI, media type and decoded bytes. Literal + remains literal in the mixed cases; metadata containing %2F stays unchanged in the stored URI.
- Restoring only
_types.pyto the PR's original merge base9c8a3514a15a702f81bfda456d80c7ccaa4d2712produces 8 genuine invalid-base64 failures and 4 passing literal-URI controls. The same 12 cases all pass on this head. - The complete
packages/core/tests/core/test_types.pypasses: 508 tests, zero skips. - The normal changed-file
prekchecks pass, with 4 nonapplicable hook skips and no tracked source or configuration changes afterward.
This is a focused factual COMMENT, not whole-PR approval. No live provider/model calls, other OS/Python lanes, complete workspace tests or distribution build were run by this review. The contributor's source/branch and PR description remain unchanged, and no competing fix was opened. AI assistance was used for the independent probes and this report.
|
BlueRaddish Thanks for the additional serialized-message coverage and baseline comparison. I checked the linked |
Motivation & Context
Equivalent literal and percent-encoded base64 data URI payloads currently produce different results: the literal PNG is detected and extracted, while its escaped form fails. Percent-decoding the payload before base64 processing restores their equivalence, as required by the Fetch data URL processor.
Description & Review Guide
unquote, which preserves literal+. The extraction helper continues to return a base64 string. Add offline regressions through public media detection and Content construction, checking decoded bytes, escaped/,+,=, lowercase escapes, raw inputs, nested escapes, metadata and errors.uv run poe test -A -m "not integration" -n 4) also passed on Linux / Python 3.12.3: 19,158 passed, 551 skipped, 2 xfailed, with 790 warnings and no failures or errors. This follows the repository default selection, excluding integration, DevUI and Lab. Live provider calls and the other Python/OS CI matrix lanes were not run locally.+survives while%252Fremains%2Fafter one decode.Related Issue
Fixes #9653.
Trivial-change exception: this is an obvious correction to the existing base64 data URI processing order, restoring equality for two representations of the same payload. It introduces no API, URI mode, decoder permissiveness, or provider-specific transformation. No maintainer agreement is claimed. Pre-publication all-state searches found no competing PR; implementation is coordinated in #9653.
AI Assistance
AI assistance details: Reproduction, implementation, regression tests, local validation and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.