Repository navigation
Fix non-base64 data URIs passing text to BytesIO - #9394
Conversation
|
Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines. |
|
Thanks, the fix is right. A data URI without One suggestion for the tests: GIF is loaded by Pillow or ffpyplayer, not the SDL3 loader, so these tests fail in an environment without Pillow. A PNG is always handled by SDL3, which keeps the test focused on the data URI decoding. For example: I checked this on master: the percent-encoded PNG raises |
|
Thanks, switched the tests to the 16x16 PNG from What I ran: on an older Kivy build without the fix, the base64 test passes and the percent-encoded one raises the TypeError, as you saw on master. I did not run it against this branch's code, so CI is the check there. |
|
LGTM! Thank you. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
Successfully created backport PR for |
A data URI without
;base64leaves its payload asstr, andImage.__init__passes it straight toBytesIO, raisingTypeError: a bytes-like object is required, not 'str'.Per RFC 2397, a non-base64 data URI payload is URL-encoded text, so decode it with
urllib.parse.unquote_to_bytesbefore handing it toBytesIO. Base64 handling is unchanged.Adds display-free tests for both branches using a percent-encoded and a base64 1x1 GIF.
Closes #9389.
Validation:
Caveat: master needs a native SDL toolchain, so the tests were run against the released 2.3.1 wheel carrying the identical data-URI branch; master's own suite was not run.