Commit 000ddc96 authored by Nick Thomas's avatar Nick Thomas

Fix the gcovr coverage regex by removing line separators before scanning

RE2 differs from Ruby in handling multiple-line strings. The string "foo\n"
will not match the regular expression "foo$" unless multi-line mode is enabled
(and it's off by default).

Since we're already scanning the build trace line by line (and so multi-line
coverage regular expressions won't work), we can fix this by removing the line
separator before scanning the string.
parent 2209426f
......@@ -74,6 +74,7 @@ module Gitlab
match = ""
reverse_line do |line|
line.chomp!
matches = regex.scan(line)
next unless matches.is_a?(Array)
next if matches.empty?
......
......@@ -300,5 +300,12 @@ describe Gitlab::Ci::Trace::Stream do
include_examples 'malicious regexp'
end
context 'multi-line data with rooted regexp' do
let(:data) { "\n65%\n" }
let(:regex) { '^(\d+)\%$' }
it { is_expected.to eq('65') }
end
end
end
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