Avoid a format validation security warning
This was actually a false positive, since our new regular expression does the exact same thing. However, false positives generate noise and make it harder to deal with real issues, so I'm changing it anyway. We could add a more advanced regular expression, like `URI::MailTo::EMAIL_REGEXP`. However, this expression marks emails with non-English characters as invalid, when in practice it's possible to have an email address with non-English characters.
This commit is contained in:
@@ -3,7 +3,7 @@ class Newsletter < ApplicationRecord
|
|||||||
|
|
||||||
validates :subject, presence: true
|
validates :subject, presence: true
|
||||||
validates :segment_recipient, presence: true
|
validates :segment_recipient, presence: true
|
||||||
validates :from, presence: true, format: { with: /@/ }
|
validates :from, presence: true, format: { with: /\A.+@.+\Z/ }
|
||||||
validates :body, presence: true
|
validates :body, presence: true
|
||||||
validate :validate_segment_recipient
|
validate :validate_segment_recipient
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user