mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ignore odd charset declaration in CONTENT_TYPE header which would throw off mime type lookup.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6340 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
0e8c3b8dd9
commit
e52c28a425
2 changed files with 21 additions and 1 deletions
|
@ -58,7 +58,8 @@ module ActionController
|
|||
def content_type
|
||||
@content_type ||=
|
||||
begin
|
||||
content_type = @env['CONTENT_TYPE'].to_s.downcase
|
||||
# Receive header sans any charset information.
|
||||
content_type = @env['CONTENT_TYPE'].to_s.sub(/\s*\;.*$/, '').strip.downcase
|
||||
|
||||
if x_post_format = @env['HTTP_X_POST_DATA_FORMAT']
|
||||
case x_post_format.to_s.downcase
|
||||
|
|
|
@ -323,6 +323,25 @@ class RequestTest < Test::Unit::TestCase
|
|||
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
||||
assert_equal Mime::JS, @request.format
|
||||
end
|
||||
|
||||
def test_content_type
|
||||
@request.env["CONTENT_TYPE"] = "text/html"
|
||||
assert_equal Mime::HTML, @request.content_type
|
||||
end
|
||||
|
||||
def test_content_no_type
|
||||
assert_equal nil, @request.content_type
|
||||
end
|
||||
|
||||
def test_content_type_xml
|
||||
@request.env["CONTENT_TYPE"] = "application/xml"
|
||||
assert_equal Mime::XML, @request.content_type
|
||||
end
|
||||
|
||||
def test_content_type_with_charset
|
||||
@request.env["CONTENT_TYPE"] = "application/xml; charset=UTF-8"
|
||||
assert_equal Mime::XML, @request.content_type
|
||||
end
|
||||
|
||||
protected
|
||||
def set_request_method_to(method)
|
||||
|
|
Loading…
Reference in a new issue