Skip to content

Preserve quoted commas in Accept media ranges - #57

Closed
ice-pring wants to merge 1 commit into
falconry:masterfrom
ice-pring:fix/quoted-media-range-commas
Closed

ice-pring wants to merge 1 commit into
falconry:masterfrom
ice-pring:fix/quoted-media-range-commas

Conversation

@ice-pring

Copy link
Copy Markdown

quality() and best_match() split Accept lists at every comma, including commas inside quoted parameter values. For example, this valid media range raises MimeTypeParseException:

media_type = 'text/plain;profile="a,b"'
mimeparse.best_match([media_type], media_type)

Split list members while tracking quoted strings and backslash escapes, as specified in RFC 9110 section 5.6.4. Preserve the original strings for parameter parsing. The common unquoted case continues to use str.split().

Added shared JSON cases for quality selection and tests covering quoted commas, escaped quotes, escaped backslashes, semicolons within quoted values, and blank list members.

Validation on Windows:

  • The added regressions produce 9 errors before the fix and pass afterward.
  • python mimeparse_test.py passes.
  • Tox py312 and py314 each pass all 6 test methods, including the shared JSON cases, on CPython 3.12.14 and 3.14.5.
  • Tox flake8 and git diff --check pass.

@ice-pring ice-pring closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant