Data-URI parsing and media-type detection are implemented several times, and each copy has been fixed separately:
Every package accepts and rejects exactly the same data URIs and reports the same media type.
from agent_framework._types import parse_data_uri
u = parse_data_uri("data:text/plain;charset=utf-8,hello%20world")
u.media_type # "text/plain"
u.params # {"charset": "utf-8"}
u.data # b"hello world"
Description
Problem
Data-URI parsing and media-type detection are implemented several times, and each copy has been fixed separately:
_validate_urirejectsdata:text/plain;charset=utf-8,...and drops the media type) and Python: [Bug]: detect_media_type_from_base64 misclassifies BMP/SVG and misses MPEG-2 audio #8906 (loose BMP/SVG sniffing, missed MPEG-2 audio, non-validated base64).Proposal
parse_data_uri(uri) -> DataUri(media_type, params, is_base64, data). It follows RFC 2397: default media typetext/plain;charset=US-ASCII, arbitrarykey=valueparams, base64 only when the last param isbase64, percent-decoding for non-base64, and a clearValueError/ContentErroron malformed input.<svgroot, the MPEG frame-sync mask, WebP/WAV RIFF subtype, andb64decode(validate=True).data:handling found in about 15 modules (A2A, hosting-A2A, AG-UI, Gemini, OpenAI Responses/Chat Completions, core MCP, hosting-MCP, DevUI, Foundry hosting, Content Understanding, skills) with the shared helper.Expected behavior
Every package accepts and rejects exactly the same data URIs and reports the same media type.
Code Sample
Language/SDK
Python