mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: 'reply by email address' validator
Prevent infinite email loophole when the 'reply_by_email_address' site setting is the same as the 'notification_email'.
This commit is contained in:
parent
4db3caec7c
commit
f7d2fc0524
6 changed files with 72 additions and 16 deletions
17
lib/validators/reply_by_email_address_validator.rb
Normal file
17
lib/validators/reply_by_email_address_validator.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class ReplyByEmailAddressValidator
|
||||
def initialize(opts={})
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
def valid_value?(val)
|
||||
return true if val.blank?
|
||||
|
||||
!!(val =~ /@/i) &&
|
||||
!!(val =~ /%{reply_key}/i) &&
|
||||
val.gsub(/\+?%{reply_key}/i, "") != SiteSetting.notification_email
|
||||
end
|
||||
|
||||
def error_message
|
||||
I18n.t('site_settings.errors.invalid_reply_by_email_address')
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue