diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-07-22 12:32:38 +0000 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-07-24 11:50:52 -0500 |
commit | ad69f367c298619a45ecb8f2f13612005fcbcacc (patch) | |
tree | a545bf9798d08843c404ea03219a1db361ca836f /lib | |
parent | 1e52495eee83be956d5d2023d72c0c149fc73ff0 (diff) | |
download | gitlab-ce-ad69f367c298619a45ecb8f2f13612005fcbcacc.tar.gz |
Merge branch 'short-circuit-coverage-with-empty-regex' into 'master'
Short-circuit build coverage extraction for empty regexes
See merge request !13015
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/untrusted_regexp.rb | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index aaba034474c..8503ecf8700 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -67,7 +67,7 @@ module Gitlab def extract_coverage(regex) return unless valid? - return unless regex + return unless regex.present? regex = Gitlab::UntrustedRegexp.new(regex) diff --git a/lib/gitlab/untrusted_regexp.rb b/lib/gitlab/untrusted_regexp.rb index 925b2158a22..187a9e1145f 100644 --- a/lib/gitlab/untrusted_regexp.rb +++ b/lib/gitlab/untrusted_regexp.rb @@ -39,7 +39,12 @@ module Gitlab groups[1..-1] end - text.slice!(0, match.end(0) || 1) + matchsize = match.end(0) + + # No further matches + break unless matchsize.present? + + text.slice!(0, matchsize) break unless text.present? end |