From 852f4a85dd199751e4652748461163de85ecda53 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 20 Feb 2020 03:08:57 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/application_setting.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/models/application_setting.rb') 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') -- cgit v1.2.3