diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index 56d6855c3c6..233cc5c1c7a 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -74,7 +74,7 @@ module Gitlab match = "" reverse_line do |line| - matches = line.scan(regex) + matches = line.force_encoding(Encoding.default_external).scan(regex) next unless matches.is_a?(Array) next if matches.empty? diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb index b4fdfd06daf..bbb3f9912a3 100644 --- a/spec/lib/gitlab/ci/trace/stream_spec.rb +++ b/spec/lib/gitlab/ci/trace/stream_spec.rb @@ -266,14 +266,14 @@ describe Gitlab::Ci::Trace::Stream do end context 'when regex is multi-byte char' do - let(:data) { 'ゴッドファット\n' } - let(:regex) { 'ゴッドファット' } + let(:data) { '95.0 ゴッドファット\n' } + let(:regex) { '\d+\.\d+ ゴッドファット' } before do stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', 5) end - it { is_expected.to be_nil } + it { is_expected.to eq('95.0') } end context 'when BUFFER_SIZE is equal to stream.size' do