diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 46ebc2a61a4a8f6d71049fd685d7ed3ad8deca26..c7820d5d9ad243288672912401313a88d0594627 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix `Mime::Type.parse` when bad accepts header is looked up. + + *Becker* + * Element of the `collection_check_boxes` and `collection_radio_buttons` can optionally contain html attributes as the last element of the array. diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 61dbf2b96c91e7680a07711b65b9d18cd9cce5ff..ef144c3c767e24b7d24e04b1328aafe17c82fead 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -175,7 +175,7 @@ def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], s def parse(accept_header) if accept_header !~ /,/ accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first - parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)] + parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact else list, index = AcceptList.new, 0 accept_header.split(',').each do |header| diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 72411ec900b3332dc2b26f49e79a298ec3649711..fd835795c0421dbc3b7bdb09f6b6a09b6cff5e75 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1089,6 +1089,12 @@ def test_should_render_formatted_html_erb_template assert_equal 'passed formatted html erb', @response.body end + def test_should_render_formatted_html_erb_template_with_bad_accepts_header + @request.env["HTTP_ACCEPT"] = "; a=dsf" + get :formatted_xml_erb + assert_equal 'passed formatted html erb', @response.body + end + def test_should_render_formatted_html_erb_template_with_faulty_accepts_header @request.accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*" get :formatted_xml_erb