From bba08d7a67e54e2a7098d1b3eb8d3faa42e0add3 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 14 Jun 2014 00:05:20 -0500 Subject: Handle non-ASCII output encoded as ASCII Some tool involved in `brew install node` is emitting UTF-8 even though LANG and LC_ALL are unset. Since the external encoding is US-ASCII, we need to guard against bad data here. --- Library/Contributions/cmd/brew-test-bot.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb index a9ad48ae2..8ffa7998c 100755 --- a/Library/Contributions/cmd/brew-test-bot.rb +++ b/Library/Contributions/cmd/brew-test-bot.rb @@ -522,7 +522,11 @@ if ARGV.include? "--junit" failure = testcase.add_element 'failure' if step.failed? if step.has_output? # Remove invalid XML CData characters from step output. - output = REXML::CData.new step.output.delete("\000\a\b\e\f") + output = step.output + if output.respond_to?(:force_encoding) && !output.valid_encoding? + output.force_encoding(Encoding::UTF_8) + end + output = REXML::CData.new output.delete("\000\a\b\e\f") if step.passed? system_out = testcase.add_element 'system-out' system_out.text = output -- cgit v1.2.3