summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-17 08:27:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-17 08:27:27 +0000
commitf165bbd0d7196f7f74a7e5ceb66f2726a9781ba7 (patch)
tree5904bc3e249b994f2634d2d1aa2bedc4de4fdb93
parentd7a6c09822bc18c01b707d479342af956f754568 (diff)
downloadredmine-f165bbd0d7196f7f74a7e5ceb66f2726a9781ba7.tar.gz
redmine-f165bbd0d7196f7f74a7e5ceb66f2726a9781ba7.zip
Use safe_attributes for email addresses.
git-svn-id: http://svn.redmine.org/redmine/trunk@15693 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/email_addresses_controller.rb5
-rw-r--r--app/models/email_address.rb4
2 files changed, 5 insertions, 4 deletions
diff --git a/app/controllers/email_addresses_controller.rb b/app/controllers/email_addresses_controller.rb
index 27c9fd22b..2fb6b2978 100644
--- a/app/controllers/email_addresses_controller.rb
+++ b/app/controllers/email_addresses_controller.rb
@@ -29,10 +29,7 @@ class EmailAddressesController < ApplicationController
saved = false
if @user.email_addresses.count <= Setting.max_additional_emails.to_i
@address = EmailAddress.new(:user => @user, :is_default => false)
- attrs = params[:email_address]
- if attrs.is_a?(Hash)
- @address.address = attrs[:address].to_s
- end
+ @address.safe_attributes = params[:email_address]
saved = @address.save
end
diff --git a/app/models/email_address.rb b/app/models/email_address.rb
index ae16b9434..cb6e2fbfe 100644
--- a/app/models/email_address.rb
+++ b/app/models/email_address.rb
@@ -16,6 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class EmailAddress < ActiveRecord::Base
+ include Redmine::SafeAttributes
+
belongs_to :user
attr_protected :id
@@ -29,6 +31,8 @@ class EmailAddress < ActiveRecord::Base
validates_uniqueness_of :address, :case_sensitive => false,
:if => Proc.new {|email| email.address_changed? && email.address.present?}
+ safe_attributes 'address'
+
def address=(arg)
write_attribute(:address, arg.to_s.strip)
end