detect_media_type_from_base64(data_uri=...) currently indexes the result of splitting on ;base64, before validating that the delimiter exists.
Malformed or non-base64 data URI inputs can therefore leak an implementation-level IndexError instead of the documented ValueError contract for invalid caller input.
Example inputs:
detect_media_type_from_base64(data_uri="data:text/plain,hello")
detect_media_type_from_base64(data_uri="data:image/png;base64")
detect_media_type_from_base64(data_uri="not-a-data-uri")
Expected behavior: invalid data_uri shapes fail with a clear ValueError rather than IndexError.
Related PR: #6916
detect_media_type_from_base64(data_uri=...)currently indexes the result of splitting on;base64,before validating that the delimiter exists.Malformed or non-base64 data URI inputs can therefore leak an implementation-level
IndexErrorinstead of the documentedValueErrorcontract for invalid caller input.Example inputs:
Expected behavior: invalid
data_urishapes fail with a clearValueErrorrather thanIndexError.Related PR: #6916