diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-26 01:19:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-26 01:19:18 +0000 |
commit | a72fe4ea45a94a09a8c31377fad935af6465b700 (patch) | |
tree | 20dd3f5df0d3adc7d40aa50aff22ac0b39cfd6da | |
parent | 89c79b8b9537b5ae8a4d3307e719b6ff6acef6f2 (diff) | |
download | rails-a72fe4ea45a94a09a8c31377fad935af6465b700.tar.gz rails-a72fe4ea45a94a09a8c31377fad935af6465b700.tar.bz2 rails-a72fe4ea45a94a09a8c31377fad935af6465b700.zip |
Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7126 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 14 | ||||
-rw-r--r-- | actionpack/test/controller/request_test.rb | 10 |
3 files changed, 20 insertions, 6 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index dc0ce55acd..3fd9a7dba8 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility. [Jeremy Kemper] + * Fixed that link_to with an href of # when using :method will not allow for click-through without JavaScript #7037 [stevenbristol/josh] * Fixed that radio_button_tag should generate unique ids #3353 [BobSilva/rebecca/josh] diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 5dbd4db9f5..528f076c24 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -68,9 +68,7 @@ module ActionController # For backward compatibility, the post format is extracted from the # X-Post-Data-Format HTTP header if present. def content_type - @content_type ||= - content_type_from_legacy_post_data_format_header || - Mime::Type.lookup(content_type_without_parameters) + @content_type ||= Mime::Type.lookup(content_type_without_parameters) end # Returns the accepted MIME type for the request @@ -296,8 +294,10 @@ module ActionController protected # The raw content type string. Use when you need parameters such as # charset or boundary which aren't included in the content_type MIME type. + # Overridden by the X-POST_DATA_FORMAT header for backward compatibility. def content_type_with_parameters - env['CONTENT_TYPE'].to_s + content_type_from_legacy_post_data_format_header || + env['CONTENT_TYPE'].to_s end # The raw content type string with its parameters stripped off. @@ -309,8 +309,8 @@ module ActionController def content_type_from_legacy_post_data_format_header if x_post_format = @env['HTTP_X_POST_DATA_FORMAT'] case x_post_format.to_s.downcase - when 'yaml'; Mime::YAML - when 'xml'; Mime::XML + when 'yaml'; 'application/x-yaml' + when 'xml'; 'application/xml' end end end @@ -319,6 +319,8 @@ module ActionController return {} if content_length.zero? content_type, boundary = self.class.extract_multipart_boundary(content_type_with_parameters) + + # Don't parse params for unknown requests. return {} if content_type.blank? mime_type = Mime::Type.lookup(content_type) diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 49c404244f..b45e7f8771 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -758,3 +758,13 @@ class XmlParamsParsingTest < Test::Unit::TestCase ActionController::CgiRequest.new(cgi).request_parameters end end + +class LegacyXmlParamsParsingTest < XmlParamsParsingTest + private + def parse_body(body) + env = { 'HTTP_X_POST_DATA_FORMAT' => 'xml', + 'CONTENT_LENGTH' => body.size.to_s } + cgi = ActionController::Integration::Session::MockCGI.new(env, body) + ActionController::CgiRequest.new(cgi).request_parameters + end +end |