diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 00:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 00:09:24 +0000 |
commit | 2711c26beaca6c3a5a3be4b65e01557faf0185b6 (patch) | |
tree | 25d0c2ddb47e87712044884f558a9104c686805f /app/validators | |
parent | 8a7aaf86831d2a556578ae558a4fcab8bb659b20 (diff) | |
download | gitlab-ce-2711c26beaca6c3a5a3be4b65e01557faf0185b6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/untrusted_regexp_validator.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/validators/untrusted_regexp_validator.rb b/app/validators/untrusted_regexp_validator.rb new file mode 100644 index 00000000000..02ed7dfb4ed --- /dev/null +++ b/app/validators/untrusted_regexp_validator.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class UntrustedRegexpValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + return unless value + + Gitlab::UntrustedRegexp.new(value) + + rescue RegexpError => e + record.errors.add(attribute, "not valid RE2 syntax: #{e.message}") + end +end |