Use Hash#reject that returns a Hash with ruby1.8 when Hash#select that returns an Array.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12016 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-07-13 10:39:36 +00:00
parent 0087d237f7
commit 594589e0ec
1 changed files with 4 additions and 2 deletions

View File

@ -453,12 +453,14 @@ class Issue < ActiveRecord::Base
if attrs['custom_field_values'].present?
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
attrs['custom_field_values'] = attrs['custom_field_values'].select {|k, v| editable_custom_field_ids.include? k.to_s}
# TODO: use #select when ruby1.8 support is dropped
attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| !editable_custom_field_ids.include?(k.to_s)}
end
if attrs['custom_fields'].present?
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
attrs['custom_fields'] = attrs['custom_fields'].select {|c| editable_custom_field_ids.include? c['id'].to_s}
# TODO: use #select when ruby1.8 support is dropped
attrs['custom_fields'] = attrs['custom_fields'].reject {|c| !editable_custom_field_ids.include?(c['id'].to_s)}
end
# mass-assignment security bypass