You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in actionpack/test/dispatch/mime_type_test.rb add the following tests;
test"works1"doaccept="*/*;q=0.2"expect=["*/*"]assert_equalexpect.map(&:to_s),Mime::Type.parse(accept).map(&:to_s)endtest"works2"doaccept="foo/*;q=0.2 abc=123"expect=["foo/*"]assert_equalexpect.map(&:to_s),Mime::Type.parse(accept).map(&:to_s)endtest"works3"doaccept="*/*;q=1.0 abc=123"expect=["*/*"]assert_equalexpect.map(&:to_s),Mime::Type.parse(accept).map(&:to_s)end# The test below should pass but it does not ------------test"doesnt_work2"doaccept="*/*;abc=123"expect=["*/*;abc=123"]assert_equalexpect.map(&:to_s),Mime::Type.parse(accept).map(&:to_s)end
Expected behavior
The test cases should all pass because */*;abc=123 is a valid accept header value
The RFC doesn't make any distinction between */* and a full type / subtype, the parameter should be allowed.
Each media-range might be followed by zero or more applicable media
type parameters (e.g., charset), an optional "q" parameter for
indicating a relative weight (Section 5.3.1), and then zero or more
extension parameters.
Actual behavior
The test case fails.
System configuration
Rails version: Rails 7.2.0.alpha
However I've noticed the behaviour from Rails 7.1.0 onwards. (Rails 7.0.8.1 does not have the same problem)
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.
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.
Steps to reproduce
It's very easy to demonstrate in the test files:
in
actionpack/test/dispatch/mime_type_test.rb
add the following tests;Expected behavior
The test cases should all pass because
*/*;abc=123
is a valid accept header valueRelevant RFC section
The RFC doesn't make any distinction between
*/*
and a fulltype / subtype
, the parameter should be allowed.Actual behavior
The test case fails.
System configuration
Rails version:
Rails 7.2.0.alpha
However I've noticed the behaviour from Rails 7.1.0 onwards. (Rails 7.0.8.1 does not have the same problem)
Ruby version:
ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [arm64-darwin22]
The text was updated successfully, but these errors were encountered: