summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/trace/stream.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/trace/stream.rb')
-rw-r--r--lib/gitlab/ci/trace/stream.rb11
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