diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-17 11:37:19 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-17 11:37:19 +0000 |
commit | 970f962451a18a5ba0441b9d869a4cb5bc9b97a3 (patch) | |
tree | 789408112dac8edc0c089b4a975781ff2166068c /lib/gitlab/ci/trace | |
parent | eeaeb2752a589c9046659d58d4a3f6be8030b699 (diff) | |
parent | 9350b9064cb9c5048f9eab8041e953a5dab5b154 (diff) | |
download | gitlab-ce-970f962451a18a5ba0441b9d869a4cb5bc9b97a3.tar.gz |
Merge branch 'fix-trace-encoding' into 'master'
Explicitly give Encoding.default_external for trace
Closes #30796
See merge request !10728
Diffstat (limited to 'lib/gitlab/ci/trace')
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index 3b335cdfd01..b929bdd55bc 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -14,6 +14,14 @@ module Gitlab def initialize @stream = yield + if @stream + @stream.binmode + # Ci::Ansi2html::Converter would read from @stream directly, + # using @stream.each_line to be specific. It's safe to set + # the encoding here because IO#seek(bytes) and IO#read(bytes) + # are not characters based, so encoding doesn't matter to them. + @stream.set_encoding(Encoding.default_external) + end end def valid? @@ -51,7 +59,7 @@ module Gitlab read_last_lines(last_lines) else stream.read - end + end.force_encoding(Encoding.default_external) end def html_with_state(state = nil) @@ -113,7 +121,6 @@ module Gitlab end chunks.join.lines.last(last_lines).join - .force_encoding(Encoding.default_external) end end end |