diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-08 15:55:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-08 16:14:47 -0700 |
commit | 8301969df9fd76bcde140f310300349b609e2b10 (patch) | |
tree | 594e82537204d89e4c1c91ff67a4fab4553ec5bb /actionpack/lib/action_dispatch | |
parent | bf8b22b392266550d3edd5d15d0cfc1589d7b88a (diff) | |
download | rails-8301969df9fd76bcde140f310300349b609e2b10.tar.gz rails-8301969df9fd76bcde140f310300349b609e2b10.tar.bz2 rails-8301969df9fd76bcde140f310300349b609e2b10.zip |
handle implicit rendering correctly
If someone sets just a charset, but depends on the implicit type from
rendering, this will store a strange content type header that looks like
this: `; charset=blah`. This is so that when the content type header
is parsed again, it will return nil for the actual type.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index d6b6ef2cff..8efc905384 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -208,7 +208,7 @@ module ActionDispatch # :nodoc: if false == charset set_header CONTENT_TYPE, header_info.mime_type else - content_type = header_info.mime_type || Mime::TEXT.to_s + content_type = header_info.mime_type set_content_type content_type, charset || self.class.default_charset end end @@ -322,6 +322,7 @@ module ActionDispatch # :nodoc: def parse_content_type(content_type) if content_type type, charset = content_type.split(/;\s*charset=/) + type = nil if type.empty? ContentTypeHeader.new(type, charset) else ContentTypeHeader.new(nil, nil) @@ -329,7 +330,7 @@ module ActionDispatch # :nodoc: end def set_content_type(content_type, charset) - type = content_type.dup + type = (content_type || '').dup type << "; charset=#{charset}" if charset set_header CONTENT_TYPE, type end @@ -356,7 +357,7 @@ module ActionDispatch # :nodoc: end def assign_default_content_type_and_charset! - return if get_header(CONTENT_TYPE).present? + return if content_type ct = parse_content_type get_header(CONTENT_TYPE) set_content_type(ct.mime_type || Mime::HTML.to_s, |