Details
-
Bug
-
Status: Ready for Engineering
-
Major
-
Resolution: Unresolved
-
PUP 4.5.2
-
None
-
-
Coremunity
-
5
Description
When shelling out to call external applications, Puppet does not ensure that stdin / stdout / stderr streams are capable of handling Unicode.
On Ruby 2.1.9 I was able to reproduce this pretty easily. A fix should include specifying encodings to the file streams that get ultimately passed to the CreateProcessW Windows API call.
glenn.sarti has produced some tests demonstrating the behavior:
describe "#execute (Windows) STDOUT", :if => Puppet.features.microsoft_windows? do
|
let(:utf8text) do
|
"utf8testfile" + [195, 164].pack('c*').force_encoding(Encoding::UTF_8)
|
end
|
let(:temputf8filename) do
|
script_containing(utf8text, :windows => "@ECHO OFF\nECHO #{utf8text}\nEXIT 100")
|
end
|
|
it "should execute with non-english characters in command line" do
|
result = Puppet::Util::Execution.execute("cmd /c \"#{temputf8filename}\"", :failonfail => false)
|
expect(temputf8filename.encoding.name).to eq('UTF-8')
|
expect(result.exitstatus).to eq(100)
|
expect(result).to eq(utf8text)
|
end
|
end
|
Current results:
DL is deprecated, please use Fiddle
|
Run options:
|
include {:locations=>{"./spec/integration/util/execution_spec.rb"=>[43]}}
|
exclude {:broken=>true, :benchmark=>true}
|
|
Puppet::Util::Execution
|
#execute (Windows) STDOUT
|
should execute with non-english characters in command line (FAILED - 1)
|
|
Failures:
|
|
1) Puppet::Util::Execution#execute (Windows) STDOUT should execute with non-en
|
glish characters in command line
|
Failure/Error: expect(result).to eq(utf8text)
|
|
expected: "utf8testfile\u00E4"
|
got: "utf8testfileä\n"
|
|
(compared using ==)
|
|
Diff:
|
@@ -1,2 +1,2 @@
|
-utf8testfileä
|
+utf8testfileä
|
# ./spec/integration/util/execution_spec.rb:48:in `block (3 levels) in <top
|
(required)>'
|
|
Finished in 1.08 seconds (files took 1.95 seconds to load)
|
1 example, 1 failure
|
Files are created in Puppet::Util::Execution.execute at https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/execution.rb#L187-L189 and in multiple locations in Uniquefile at https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_system/uniquefile.rb#L39-L53
I have been able to solve the problem, but the current solution is unsatisfactory, as it requires changes to the file modes and the global Windows codepage to be set with chcp 65001 to Unicode.
Attachments
Issue Links
- relates to
-
PUP-7267 Execution API
-
- Open
-
-
PUP-1435 Puppet::Util::execute semantics, on Windows, don't match POSIX or Puppet expectations.
-
- Ready for Engineering
-
-
PUP-5798 Puppet::Util::Execution.execute does not support UTF8 chars reported from STDOUT
-
- Closed
-
-
PUP-7063 Handle incompatible encodings in Puppet::Util::Log when rendering to console
-
- Closed
-
-
MODULES-3275 Chocolatey Module Test Automation Creation
-
- Resolved
-
-
PUP-6986 Service provider fails when hasstatus => false and the output of 'ps -ef' happens to contains non-ASCII chars
-
- Closed
-
-
PUP-1401 Puppet package providers use execpipe, which does not set LC_ALL or LANG
-
- Accepted
-
-
PUP-1477 provider command throws exception on unicode
-
- Closed
-
-
PUP-5768 Fix problematic usage of ENV for Windows
-
- Closed
-
-
PUP-7268 SPIKE: Puppet::Util::Execution rewrite
-
- Closed
-