FIX: ReplyByEmailAddressValidator should leverage EmailAddressValidator

Since we already have perfectly sensible logic for validating email addresses,
let's leverage that and simplify the logic while we're at it.

Emails with spaces are no longer permitted (why were they?)
This commit is contained in:
Michael Brown 2022-02-17 20:18:34 -05:00 committed by Michael Brown
parent 3bf3b9a4a5
commit a312b9ae88

View File

@ -7,17 +7,14 @@ class ReplyByEmailAddressValidator
def valid_value?(val)
return true if val.blank?
return false if !val.include?("@")
value = val.dup
value.strip!
return false if !EmailAddressValidator.valid_value?(val)
if SiteSetting.find_related_post_with_key
return false if !value.include?("%{reply_key}")
value.sub!(/\+?%{reply_key}/, "")
return false if !val.include?("%{reply_key}")
val.sub(/\+?%{reply_key}/, "") != SiteSetting.notification_email
else
val != SiteSetting.notification_email
end
value != SiteSetting.notification_email && !value.include?(" ")
end
def error_message