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:
Régis Hanol
2015-02-06 12:08:37 +01:00
parent 4db3caec7c
commit f7d2fc0524
6 changed files with 72 additions and 16 deletions

View 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