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 undefined method `ref' for nil:NilClass for bad accept headers #11000

Merged
merged 1 commit into from Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions 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.

Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/mime_type.rb
Expand Up @@ -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|
Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -1089,6 +1089,12 @@ def test_should_render_formatted_html_erb_template
assert_equal '<test>passed formatted html erb</test>', @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 '<test>passed formatted html erb</test>', @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
Expand Down