diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-09 17:09:00 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-09 17:09:00 -0700 |
commit | 573999f631c662c9bb111d1a6ce61c7f61d6c85c (patch) | |
tree | 2cfd7bc74050632481c78415b3701d818461b2fd | |
parent | b57ede8e5d829f623aceb7d7b77631f9c63d539f (diff) | |
download | chef-573999f631c662c9bb111d1a6ce61c7f61d6c85c.tar.gz |
Sometimes plutil returns an invalid utf-8 string, which gets interpreted as ascii
This causes plist gem to crash
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 0726b08ded..0c0c85e18b 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -652,7 +652,11 @@ user password using shadow hash.") def run_plutil(*args) result = shell_out("plutil -#{args.join(' ')}") raise(Chef::Exceptions::PlistUtilCommandFailed,"plutil error: #{result.inspect}") unless result.exitstatus == 0 - result.stdout + if result.stdout.encoding == Encoding::ASCII_8BIT + result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => '?') + else + result.stdout + end end def convert_binary_plist_to_xml(binary_plist_string) |