提交 8ffd139e 编写于 作者: S Stephen Becker IV

Fix undefined method `ref' for nil:NilClass for bad accept headers

上级 0f89689b
* 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.
......
......@@ -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|
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册