Make it possible to compare untrusted regexps
This commit is contained in:
parent
1736d74408
commit
6d0c10b1b7
1 changed files with 5 additions and 1 deletions
|
@ -9,7 +9,7 @@ module Gitlab
|
|||
# there is a strict limit on total execution time. See the RE2 documentation
|
||||
# at https://github.com/google/re2/wiki/Syntax for more details.
|
||||
class UntrustedRegexp
|
||||
delegate :===, to: :regexp
|
||||
delegate :===, :source, to: :regexp
|
||||
|
||||
def initialize(pattern)
|
||||
@regexp = RE2::Regexp.new(pattern, log_errors: false)
|
||||
|
@ -31,6 +31,10 @@ module Gitlab
|
|||
RE2.Replace(text, regexp, rewrite)
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
self.source == other.source
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :regexp
|
||||
|
|
Loading…
Reference in a new issue