Commit 6d0c10b1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make it possible to compare untrusted regexps

parent 1736d744
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
# there is a strict limit on total execution time. See the RE2 documentation # there is a strict limit on total execution time. See the RE2 documentation
# at https://github.com/google/re2/wiki/Syntax for more details. # at https://github.com/google/re2/wiki/Syntax for more details.
class UntrustedRegexp class UntrustedRegexp
delegate :===, to: :regexp delegate :===, :source, to: :regexp
def initialize(pattern) def initialize(pattern)
@regexp = RE2::Regexp.new(pattern, log_errors: false) @regexp = RE2::Regexp.new(pattern, log_errors: false)
...@@ -31,6 +31,10 @@ module Gitlab ...@@ -31,6 +31,10 @@ module Gitlab
RE2.Replace(text, regexp, rewrite) RE2.Replace(text, regexp, rewrite)
end end
def ==(other)
self.source == other.source
end
private private
attr_reader :regexp attr_reader :regexp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment