Welcome to mirror list, hosted at ThFree Co, Russian Federation.

untrusted_regexp_validator.rb « validators « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 02ed7dfb4edf02d48f122fe906ea62f10e65070f (plain)
1
2
3
4
5
6
7
8
9
10
11
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