aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrosser <grosser.michael@gmail.com>2012-09-22 19:36:45 -0700
committergrosser <grosser.michael@gmail.com>2012-09-24 17:24:18 -0700
commit9e2948e750fa3f641f20adad4b4ecae89b35faa7 (patch)
treefb7809b1bf5cf07c815568153570eb1fa95301b5
parent133d42bc0fe4926800ff91a587e2ebeb405c3a11 (diff)
downloadrails-9e2948e750fa3f641f20adad4b4ecae89b35faa7.tar.gz
rails-9e2948e750fa3f641f20adad4b4ecae89b35faa7.tar.bz2
rails-9e2948e750fa3f641f20adad4b4ecae89b35faa7.zip
depreacte unused Mime::Type#verify_request? and Mime::Type.browser_generated_types
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb7
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb8
-rw-r--r--actionpack/test/dispatch/rack_test.rb12
4 files changed, 24 insertions, 8 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 5a3b4dc4a2..be33b5cd38 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Deprecate Mime::Type#verify_request? and Mime::Type.browser_generated_types,
+ since they are no longer used inside of Rails, they will be removed in Rails 4.1
+
+ *Michael Grosser*
+
* `ActionDispatch::Http::UploadedFile` now delegates `close` to its tempfile. *Sergio Gil*
* Add `ActionController::StrongParameters`, this module converts `params` hash into
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index f86ae26b8a..3d560518e1 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -57,7 +57,6 @@ module Mime
# i.e. following a link, getting an image or posting a form. CSRF protection
# only needs to protect against these types.
@@browser_generated_types = Set.new [:html, :url_encoded_form, :multipart_form, :text]
- cattr_reader :browser_generated_types
attr_reader :symbol
@register_callbacks = []
@@ -276,9 +275,15 @@ module Mime
# Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
# ActionController::RequestForgeryProtection.
def verify_request?
+ ActiveSupport::Deprecation.warn "Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1"
@@browser_generated_types.include?(to_sym)
end
+ def self.browser_generated_types
+ ActiveSupport::Deprecation.warn "Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1"
+ @@browser_generated_types
+ end
+
def html?
@@html_types.include?(to_sym) || @string =~ /html/
end
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index 3e83f3d4fa..e2a9ba782d 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -185,9 +185,11 @@ class MimeTypeTest < ActiveSupport::TestCase
all_types.uniq!
# Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE
all_types.delete_if { |type| !Mime.const_defined?(type.upcase) }
- verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
- assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
- assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ assert_deprecated do
+ verified, unverified = all_types.partition { |type| Mime::Type.browser_generated_types.include? type }
+ assert verified.each { |type| assert Mime.const_get(type.upcase).verify_request?, "Verifiable Mime Type is not verified: #{type.inspect}" }
+ assert unverified.each { |type| assert !Mime.const_get(type.upcase).verify_request?, "Nonverifiable Mime Type is verified: #{type.inspect}" }
+ end
end
test "references gives preference to symbols before strings" do
diff --git a/actionpack/test/dispatch/rack_test.rb b/actionpack/test/dispatch/rack_test.rb
index 698f980296..6d239d0a0c 100644
--- a/actionpack/test/dispatch/rack_test.rb
+++ b/actionpack/test/dispatch/rack_test.rb
@@ -176,13 +176,17 @@ end
class RackRequestContentTypeTest < BaseRackTest
test "html content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
- assert @request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::HTML.to_s
+ assert @request.content_mime_type.verify_request?
+ end
end
test "xml content type verification" do
- @request.env['CONTENT_TYPE'] = Mime::XML.to_s
- assert !@request.content_mime_type.verify_request?
+ assert_deprecated do
+ @request.env['CONTENT_TYPE'] = Mime::XML.to_s
+ assert !@request.content_mime_type.verify_request?
+ end
end
end