Skip to content

parse_data_uri rejects valid data URLs with an omitted media type #3783

Description

@dajiaohuang

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

Activity

added this to the 3.1.7 milestone on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions