diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/version.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation/where_test.rb | 6 |
4 files changed, 17 insertions, 5 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 71050efbc5..aa6634517e 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,4 +1,10 @@ -## Rails 3.2.6 (unreleased) ## +## Rails 3.2.6 (Jun 12, 2012) ## + +* protect against the nesting of hashes changing the + table context in the next call to build_from_hash. This fix + covers this case as well. + + CVE-2012-2695 * Revert earlier 'perf fix' (see 3.2.4 changelog / GH #6289). This change introduced a regression (GH #6609). assoc.clear and diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 9c84d8a6d5..6b118b4912 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -1,16 +1,16 @@ module ActiveRecord class PredicateBuilder # :nodoc: - def self.build_from_hash(engine, attributes, default_table, check_column = true) + def self.build_from_hash(engine, attributes, default_table, allow_table_name = true) predicates = attributes.map do |column, value| table = default_table - if value.is_a?(Hash) + if allow_table_name && value.is_a?(Hash) table = Arel::Table.new(column, engine) build_from_hash(engine, value, table, false) else column = column.to_s - if check_column && column.include?('.') + if allow_table_name && column.include?('.') table_name, column = column.split('.', 2) table = Arel::Table.new(table_name, engine) end diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb index d2bfa51a8a..43fc292302 100644 --- a/activerecord/lib/active_record/version.rb +++ b/activerecord/lib/active_record/version.rb @@ -2,7 +2,7 @@ module ActiveRecord module VERSION #:nodoc: MAJOR = 3 MINOR = 2 - TINY = 5 + TINY = 6 PRE = nil STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb index 90c690e266..b9eef1d32f 100644 --- a/activerecord/test/cases/relation/where_test.rb +++ b/activerecord/test/cases/relation/where_test.rb @@ -11,6 +11,12 @@ module ActiveRecord end end + def test_where_error_with_hash + assert_raises(ActiveRecord::StatementInvalid) do + Post.where(:id => { :posts => {:author_id => 10} }).first + end + end + def test_where_with_table_name post = Post.first assert_equal post, Post.where(:posts => { 'id' => post.id }).first |