summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-10-07 03:43:00 +0000
committerGo MAEDA <maeda@farend.jp>2023-10-07 03:43:00 +0000
commit43873746bae72f620d4813977447ea59db37fbe5 (patch)
tree65021caf56e2f75b5c3932cb6449d5e46c1b0325 /app
parent090323b7a0863e6ca4cf85272bfab308056f0841 (diff)
downloadredmine-43873746bae72f620d4813977447ea59db37fbe5.tar.gz
redmine-43873746bae72f620d4813977447ea59db37fbe5.zip
Replace custom EMAIL_REGEXP with URI::MailTo::EMAIL_REGEXP for more accurate email validation (#36969).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22332 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/email_address.rb4
-rw-r--r--app/models/setting.rb2
2 files changed, 2 insertions, 4 deletions
diff --git a/app/models/email_address.rb b/app/models/email_address.rb
index 5a0f32abe..cc9064e04 100644
--- a/app/models/email_address.rb
+++ b/app/models/email_address.rb
@@ -20,8 +20,6 @@
class EmailAddress < ActiveRecord::Base
include Redmine::SafeAttributes
- EMAIL_REGEXP = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+(?:(?:xn--[-a-z0-9]+)|(?:[a-z]{2,})))\z/i
-
belongs_to :user
after_update :destroy_tokens
@@ -32,7 +30,7 @@ class EmailAddress < ActiveRecord::Base
after_destroy_commit :deliver_security_notification_destroy
validates_presence_of :address
- validates_format_of :address, :with => EMAIL_REGEXP, :allow_blank => true
+ validates_format_of :address, :with => URI::MailTo::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?}
diff --git a/app/models/setting.rb b/app/models/setting.rb
index 81f121db4..a44f92ce3 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -187,7 +187,7 @@ class Setting < ActiveRecord::Base
if settings.key?(:mail_from)
begin
mail_from = Mail::Address.new(settings[:mail_from])
- raise unless EmailAddress::EMAIL_REGEXP.match?(mail_from.address)
+ raise unless URI::MailTo::EMAIL_REGEXP.match?(mail_from.address)
rescue
messages << [:mail_from, l('activerecord.errors.messages.invalid')]
end