Fix issue with attr_protected where malformed input could circumvent

protection

Fixes: CVE-2013-0276

Conflicts:
	activemodel/lib/active_model/attribute_methods.rb
	activerecord/test/cases/mass_assignment_security_test.rb
This commit is contained in:
joernchen of Phenoelit
2013-02-09 15:46:44 -08:00
committed by Aaron Patterson
parent f93d046770
commit 2dfd51247f
2 changed files with 2 additions and 2 deletions

View File

@@ -347,7 +347,7 @@ module ActiveModel
def initialize(options = {})
options.symbolize_keys!
@prefix, @suffix = options[:prefix] || '', options[:suffix] || ''
@regex = /^(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})$/
@regex = /\A(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})\z/
end
def match(method_name)

View File

@@ -17,7 +17,7 @@ module ActiveModel
protected
def remove_multiparameter_id(key)
key.to_s.gsub(/\(.+/, '')
key.to_s.gsub(/\(.+/m, '')
end
end