Uh oh!
There was an error while loading. Please reload this page.
fix: audio() mishandles data: URIs (mislabels format) - #8
Merged
Conversation
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.
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 freeto 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#2
Fix
In
audio():_mime_from_data_url) and use its subtype asformat—data:audio/mpeg;…→mpeg→ serveraudio/mpeg._assert_allowedcheck the other builders use.auto_partnow forwards the detected format instead of dropping it.URL inputs are unchanged (
…/a.mp3→mp3,…/a.wav→wav). Note the intentional asymmetry the issue prescribes: URL-mp3 →audio/mp3, data-URI-mp3 →audio/mpegboth accepted by the server.Tests
Added regression tests asserting the literal
format(data:audio/mpeg→mpeg,data:audio/wav→wav), a blacklisted data-URI rejection, andauto_partforwarding. Full suite: 27 passing;ruff+mypy --strictclean.