Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #100 from cabeca/better-encode

Better encode
  • Loading branch information...
commit ad65ca37284b62f16180d119fc887d393494fb18 2 parents 38b6a2a + 3547111
Dmitriy Zaporozhets randx authored
22 app/models/build.rb
View
@@ -81,8 +81,7 @@ def commit
def write_trace(trace)
self.reload
- sanitized_output = sanitize_build_output(trace)
- update_attributes(trace: sanitized_output)
+ update_attributes(trace: trace)
end
def short_before_sha
@@ -94,22 +93,12 @@ def short_sha
end
def trace_html
- if trace.present?
- Ansi2html::convert(compose_output)
- else
- ''
- end
- end
-
- def sanitize_build_output(output)
- GitlabCi::Encode.encode!(output)
+ html = Ansi2html::convert(compose_output) if trace.present?
+ html ||= ''
end
def read_tmp_file
- content = if tmp_file && File.readable?(tmp_file)
- File.read(tmp_file)
- end
-
+ content = GitlabCi::Encode.encode!(File.binread(tmp_file)) if tmp_file && File.readable?(tmp_file)
content ||= ''
end
@@ -117,8 +106,7 @@ def compose_output
output = trace
if running?
- sanitized_output = sanitize_build_output(read_tmp_file)
- output << sanitized_output if sanitized_output.present?
+ output << read_tmp_file
end
output
1  config/initializers/encoding_detection.rb
View
@@ -1 +0,0 @@
-require 'charlock_holmes/string'
2  lib/gitlab_ci/encode.rb
View
@@ -1,3 +1,5 @@
+require 'charlock_holmes/string'
+
module GitlabCi
module Encode
extend self
6 lib/runner.rb
View
@@ -75,7 +75,7 @@ def command(cmd, path)
@output << "\n"
@process = ChildProcess.build(cmd)
- @tmp_file = Tempfile.new("child-output")
+ @tmp_file = Tempfile.new("child-output", binmode: true)
@process.io.stdout = @tmp_file
@process.io.stderr = @tmp_file
@process.cwd = path
@@ -99,7 +99,9 @@ def command(cmd, path)
@process.exit_code == 0
ensure
@tmp_file.rewind
- @output << @tmp_file.read
+ @output << GitlabCi::Encode.encode!(@tmp_file.read)
+ @tmp_file.close
+ @tmp_file.unlink
end
def prepare_project_cmd(path, ref)
Please sign in to comment.
Something went wrong with that request. Please try again.