summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-11 13:28:51 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-05-11 13:28:51 +0200
commit6d0c10b1b791e1938ce42c332280f5fe7dcd489f (patch)
treeed9c77fa21239e33e1d2cc1e7a1ddeaa7a77a054
parent1736d74408a406468d9f66e4dda1a1492793b8d3 (diff)
downloadgitlab-ce-6d0c10b1b791e1938ce42c332280f5fe7dcd489f.tar.gz
Make it possible to compare untrusted regexps
-rw-r--r--lib/gitlab/untrusted_regexp.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/untrusted_regexp.rb b/lib/gitlab/untrusted_regexp.rb
index 7ce2e9d636e..fb25755391d 100644
--- a/lib/gitlab/untrusted_regexp.rb
+++ b/lib/gitlab/untrusted_regexp.rb
@@ -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