Commit a6f6056c authored by Shinya Maeda's avatar Shinya Maeda

Use force_encoding when regex contains UTF-8 char

parent b9950c22
...@@ -74,7 +74,7 @@ module Gitlab ...@@ -74,7 +74,7 @@ module Gitlab
match = "" match = ""
reverse_line do |line| reverse_line do |line|
matches = line.scan(regex) matches = line.force_encoding(Encoding.default_external).scan(regex)
next unless matches.is_a?(Array) next unless matches.is_a?(Array)
next if matches.empty? next if matches.empty?
......
...@@ -266,14 +266,14 @@ describe Gitlab::Ci::Trace::Stream do ...@@ -266,14 +266,14 @@ describe Gitlab::Ci::Trace::Stream do
end end
context 'when regex is multi-byte char' do context 'when regex is multi-byte char' do
let(:data) { 'ゴッドファット\n' } let(:data) { '95.0 ゴッドファット\n' }
let(:regex) { 'ゴッドファット' } let(:regex) { '\d+\.\d+ ゴッドファット' }
before do before do
stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', 5) stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', 5)
end end
it { is_expected.to be_nil } it { is_expected.to eq('95.0') }
end end
context 'when BUFFER_SIZE is equal to stream.size' do context 'when BUFFER_SIZE is equal to stream.size' do
......
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