提交 9de9b359 编写于 作者: A Aaron Patterson

CVE-2012-5664 options hashes should only be extracted if there are extra parameters

上级 e8c05974
......@@ -1897,7 +1897,11 @@ def method_missing(method_id, *arguments, &block)
# end
self.class_eval <<-EOS, __FILE__, __LINE__ + 1
def self.#{method_id}(*args)
options = args.extract_options!
options = if args.length > #{attribute_names.size}
args.extract_options!
else
{}
end
attributes = construct_attributes_from_arguments(
[:#{attribute_names.join(',:')}],
args
......
......@@ -66,6 +66,18 @@ def test_find_or_create_by
class FinderTest < ActiveRecord::TestCase
fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors, :customers
def test_find_by_id_with_hash
assert_raises(ActiveRecord::StatementInvalid) do
Post.find_by_id(:limit => 1)
end
end
def test_find_by_title_and_id_with_hash
assert_raises(ActiveRecord::StatementInvalid) do
Post.find_by_title_and_id('foo', :limit => 1)
end
end
def test_find
assert_equal(topics(:first).title, Topic.find(1).title)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册