Skip to content

fix: audio() mishandles data: URIs (mislabels format) - #8

Merged
Khurdhula-Harshavardhan merged 1 commit into
mainfrom
fix/audio-data-uri-format
Jul 20, 2026
Merged

fix: audio() mishandles data: URIs (mislabels format)#8
Khurdhula-Harshavardhan merged 1 commit into
mainfrom
fix/audio-data-uri-format

Conversation

@Abhinavexist

@AbhinavexistAbhinavexist commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes#2

Fix

In audio():

  • Read the data-URL MIME (_mime_from_data_url) and use its subtype as formatdata:audio/mpeg;…mpeg → server audio/mpeg.
  • Run the same _assert_allowed check the other builders use.
  • auto_part now forwards the detected format instead of dropping it.

URL inputs are unchanged (…/a.mp3mp3, …/a.wavwav). Note the intentional asymmetry the issue prescribes: URL-mp3 → audio/mp3, data-URI-mp3 → audio/mpeg both accepted by the server.

Tests

Added regression tests asserting the literal format (data:audio/mpegmpeg, data:audio/wavwav), a blacklisted data-URI rejection, and auto_part forwarding. Full suite: 27 passing; ruff + mypy --strict clean.

audio() derived format from the file extension only, so a data: URI
(no extension) fell through to "wav" — mislabeling every base64 audio
part — and skipped the MIME lookup and blacklist check the other
builders run.
Read the data-URL MIME, use its subtype as the format (the server
prepends audio/), run _assert_allowed, and have auto_part forward the
detected format.

@Khurdhula-HarshavardhanKhurdhula-Harshavardhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Khurdhula-Harshavardhan
Khurdhula-Harshavardhan deleted the fix/audio-data-uri-format branch July 20, 2026 23:25
Sign up for freeto 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.

inputs.audio() mishandles data: URIs (mislabels/garbage format)

2 participants

@Abhinavexist@Khurdhula-Harshavardhan