diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-06-25 19:34:20 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-06-25 19:34:20 -0300 |
commit | dd9d8697466f111299fd9b7cf1cf565f20951e15 (patch) | |
tree | 28940f6763c52b757e236174f7500b411751e366 /actionpack | |
parent | f02d4ddc99ad70d1bd50ff70d37aed5f9cf49398 (diff) | |
parent | 8ffd139edd062fe3e888895d4af80730a0798758 (diff) | |
download | rails-dd9d8697466f111299fd9b7cf1cf565f20951e15.tar.gz rails-dd9d8697466f111299fd9b7cf1cf565f20951e15.tar.bz2 rails-dd9d8697466f111299fd9b7cf1cf565f20951e15.zip |
Merge pull request #11000 from sbeckeriv/accept_header
Fix undefined method `ref' for nil:NilClass for bad accept headers
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 6 |
3 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index e33accf854..05495179c3 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,11 @@ +* Fix `Mime::Type.parse` when bad accepts header is looked up. Previously it + was setting `request.formats` with an array containing a `nil` value, which + raised an error when setting the controller formats. + + Fixes #10965 + + *Becker* + * Merge `:action` from routing scope and assign endpoint if both `:controller` and `:action` are present. The endpoint assignment only occurs if there is no `:to` present in the options hash so should only affect routes using the diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 61dbf2b96c..ef144c3c76 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -175,7 +175,7 @@ module Mime 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 72411ec900..fd835795c0 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1089,6 +1089,12 @@ class RenderTest < ActionController::TestCase 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 |