summaryrefslogtreecommitdiffstats
path: root/app/models/email_address.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-08-26 04:18:18 +0000
committerGo MAEDA <maeda@farend.jp>2019-08-26 04:18:18 +0000
commit47dd2083f7958ff05deea3c56c1c2067fef64f9c (patch)
treea0386a6d30d3475a4788336593998813a5ec9ad8 /app/models/email_address.rb
parente03617881e5f4c1240b9d494df975968da4a9478 (diff)
downloadredmine-47dd2083f7958ff05deea3c56c1c2067fef64f9c.tar.gz
redmine-47dd2083f7958ff05deea3c56c1c2067fef64f9c.zip
Reject setting RFC non-compliant emission email addresses (#31154).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@18396 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/email_address.rb')
-rw-r--r--app/models/email_address.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/email_address.rb b/app/models/email_address.rb
index 7f8eef5da..c3d8e8d41 100644
--- a/app/models/email_address.rb
+++ b/app/models/email_address.rb
@@ -20,6 +20,8 @@
class EmailAddress < ActiveRecord::Base
include Redmine::SafeAttributes
+ EMAIL_REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
+
belongs_to :user
after_update :destroy_tokens
@@ -30,7 +32,7 @@ class EmailAddress < ActiveRecord::Base
after_destroy_commit :deliver_security_notification_destroy
validates_presence_of :address
- validates_format_of :address, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true
+ validates_format_of :address, :with => EMAIL_REGEXP, :allow_blank => true
validates_length_of :address, :maximum => User::MAIL_LENGTH_LIMIT, :allow_nil => true
validates_uniqueness_of :address, :case_sensitive => false,
:if => Proc.new {|email| email.address_changed? && email.address.present?}