diff options
author | Nick Thomas <nick@gitlab.com> | 2017-07-21 15:04:18 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-07-22 09:12:19 +0300 |
commit | 4bda5b502de35b7032f8c49a340325aeeb0d7ebe (patch) | |
tree | 087887974ab9796546f2ac225e708b0ac803e23d /lib/gitlab/untrusted_regexp.rb | |
parent | 754d8caeefdcb887a8a955155cbec436f7ae13c9 (diff) |
Short-circuit build coverage extraction for empty regexes
Diffstat (limited to 'lib/gitlab/untrusted_regexp.rb')
-rw-r--r-- | lib/gitlab/untrusted_regexp.rb | 7 |
1 files changed, 6 insertions, 1 deletions
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 |