parse_data_uri() requires a nonempty MIME type in its regular expression, but RFC 2397 allows the media type to be omitted and defaults it to text/plain;charset=US-ASCII. Its own result-building code also attempts to provide those defaults, but the required MIME capture makes that path unreachable.
For example, the RFC's valid data:,A%20brief%20note form does not match the expression. The fallback only retries when the input contains literal whitespace, so this encoded example falls through with $match unset and then reads missing capture keys. The shorthand with a charset but no text/plain type is rejected for the same reason.
Could the parser accept an omitted media type and populate the documented defaults? Static source finding; no runtime test was run.
Reference: https://www.rfc-editor.org/rfc/rfc2397#section-2
parse_data_uri()requires a nonempty MIME type in its regular expression, but RFC 2397 allows the media type to be omitted and defaults it totext/plain;charset=US-ASCII. Its own result-building code also attempts to provide those defaults, but the required MIME capture makes that path unreachable.For example, the RFC's valid
data:,A%20brief%20noteform does not match the expression. The fallback only retries when the input contains literal whitespace, so this encoded example falls through with$matchunset and then reads missing capture keys. The shorthand with a charset but notext/plaintype is rejected for the same reason.Could the parser accept an omitted media type and populate the documented defaults? Static source finding; no runtime test was run.
Reference: https://www.rfc-editor.org/rfc/rfc2397#section-2