提交 74f2b41c 编写于 作者: K kennyj

Remove Mime::Type#verify_request? and Mime::Type.browser_generated_types were deprecated.

上级 6ff923a1
...@@ -53,10 +53,6 @@ class Type ...@@ -53,10 +53,6 @@ class Type
@@html_types = Set.new [:html, :all] @@html_types = Set.new [:html, :all]
cattr_reader :html_types cattr_reader :html_types
# These are the content types which browsers can generate without using ajax, flash, etc
# 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]
attr_reader :symbol attr_reader :symbol
@register_callbacks = [] @register_callbacks = []
...@@ -272,18 +268,6 @@ def =~(mime_type) ...@@ -272,18 +268,6 @@ def =~(mime_type)
end end
end end
# 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? def html?
@@html_types.include?(to_sym) || @string =~ /html/ @@html_types.include?(to_sym) || @string =~ /html/
end end
......
...@@ -185,11 +185,6 @@ class MimeTypeTest < ActiveSupport::TestCase ...@@ -185,11 +185,6 @@ class MimeTypeTest < ActiveSupport::TestCase
all_types.uniq! all_types.uniq!
# Remove custom Mime::Type instances set in other tests, like Mime::GIF and Mime::IPHONE # 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) } all_types.delete_if { |type| !Mime.const_defined?(type.upcase) }
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 end
test "references gives preference to symbols before strings" do test "references gives preference to symbols before strings" do
......
...@@ -174,22 +174,6 @@ class RackRequestParamsParsingTest < BaseRackTest ...@@ -174,22 +174,6 @@ class RackRequestParamsParsingTest < BaseRackTest
end end
end end
class RackRequestContentTypeTest < BaseRackTest
test "html content type verification" do
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
assert_deprecated do
@request.env['CONTENT_TYPE'] = Mime::XML.to_s
assert !@request.content_mime_type.verify_request?
end
end
end
class RackRequestNeedsRewoundTest < BaseRackTest class RackRequestNeedsRewoundTest < BaseRackTest
test "body should be rewound" do test "body should be rewound" do
data = 'foo' data = 'foo'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册