diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 06:08:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 06:08:57 +0300 |
commit | 852f4a85dd199751e4652748461163de85ecda53 (patch) | |
tree | b4160aa19c23582b5ab5ac02f9860b5498007c43 /app/models/application_setting.rb | |
parent | 82cd20acf9f4cceecf222abe718a9e23cef55687 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r-- | app/models/application_setting.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index ddd43311d9b..2f7d6164b9a 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -243,6 +243,8 @@ class ApplicationSetting < ApplicationRecord validates :snippet_size_limit, numericality: { only_integer: true, greater_than: 0 } + validate :email_restrictions_regex_valid? + SUPPORTED_KEY_TYPES.each do |type| validates :"#{type}_key_restriction", presence: true, key_restriction: { type: type } end @@ -381,6 +383,14 @@ class ApplicationSetting < ApplicationRecord def recaptcha_or_login_protection_enabled recaptcha_enabled || login_recaptcha_protection_enabled end + + def email_restrictions_regex_valid? + return if email_restrictions.blank? + + Gitlab::UntrustedRegexp.new(email_restrictions) + rescue RegexpError + errors.add(:email_restrictions, _('is not a valid regular expression')) + end end ApplicationSetting.prepend_if_ee('EE::ApplicationSetting') |