Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mime::Type.parse for HTTP Accept with parameters #51616

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

notchairmk
Copy link
Contributor

@notchairmk notchairmk commented Apr 20, 2024

Motivation / Background

Fixes #51594

This Pull Request has been created because to fix valid Mime::Type parsing of media range parameters.

Detail

This Pull Request changes Mime::Type.lookup (indirectly Mime::Type.parse) to strip out custom media range parameters before falling back to default type creation. This should fix at least some 406 responses that Rails 7.1 is returning for valid HTTP Accept headers.

An example of a failure currently:

Accept: */*;encoding=UTF-8;q=0.9

Additional information

It looks like the break was initially introduced in 7.1 from #48397 .

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@rails-bot rails-bot bot added the actionpack label Apr 20, 2024
@notchairmk
Copy link
Contributor Author

I'm not sure whether or not this counts as a "minor" bug fix, so current changes have an updated changelog.

Fixes MIME parsing raising errors on valid parameters rails#51594.

Mime type lookups were updated to handle custom registered types as part of rails#48397.

This fix the strips out custom media range parameters before falling back to the default type creation.
@rafaelfranca rafaelfranca merged commit 2bb6782 into rails:main Apr 23, 2024
2 of 3 checks passed
rafaelfranca added a commit that referenced this pull request Apr 23, 2024
Fix `Mime::Type.parse` for HTTP Accept with parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[7.1] MIME parsing raising errors on valid parameters
2 participants