Repository navigation
Conversation
_load_image used split(',')[1], so a data URL without a comma raised
IndexError, and non-base64 payloads such as data:image/svg+xml,<svg>
were passed to b64decode. Decode base64 when the header says so,
unquote plain payloads, and raise ValueError when the comma is missing.
This branch has not been deployed
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 free
to 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.
Summary
Both multimodal chat handlers loaded images with
base64.b64decode(image_url.split(\",\")[1]). A data URL with no comma (for exampledata:image/png;base64) raisedIndexError, and a non-base64 payload such asdata:image/svg+xml,%3Csvg%3Ewas fed tob64decode.A shared helper now splits on the first comma, decodes base64 when the header contains
;base64(case-insensitive), unquotes plain data-URL payloads, and raisesValueErrorwhen the comma is missing.Tests
tests/test_image_url.pycovers a base64 round-trip, a;BASE64header, a missing comma, a percent-encoded SVG payload, and an HTTP URL (mocked).