diff options
author | Matt Wrock <matt@mattwrock.com> | 2016-05-06 15:23:51 -0700 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2016-05-06 15:23:51 -0700 |
commit | 3a895c6a8508fdfdba6840214855ff77122f2a67 (patch) | |
tree | d60973f6a68e468ff3a99cbd9bfe2fe6b3147fe2 /lib | |
parent | 3a982b8becf9b06a8e9ed772bb0e3912a5056254 (diff) | |
parent | 9b71a935fe373aa276393ddacc22d8fec0323132 (diff) | |
download | chef-3a895c6a8508fdfdba6840214855ff77122f2a67.tar.gz |
Merge pull request #4906 from chef/utf8_reg
Encode registry enumerated values and keys to utf8 instead of the local codepage
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/monkey_patches/win32/registry.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/chef/monkey_patches/win32/registry.rb b/lib/chef/monkey_patches/win32/registry.rb index 1c1a103432..a08d67becf 100644 --- a/lib/chef/monkey_patches/win32/registry.rb +++ b/lib/chef/monkey_patches/win32/registry.rb @@ -22,6 +22,17 @@ require "win32/registry" module Win32 class Registry + # ::Win32::Registry#export_string is used when enumerating child + # keys and values and re encodes a UTF-16LE to the local codepage. + # This can result in encoding incompatibilities if the native codepage + # does not support the characters in the registry. There is an open bug + # in ruby at https://bugs.ruby-lang.org/issues/11410. Rather than converting + # the UTF-16LE originally returned by the win32 api, we encode to UTF-8 + # which will likely not result in any conversion error. + def export_string(str, enc = Encoding.default_internal || "utf-8") + str.encode(enc) + end + module API extend Chef::ReservedNames::Win32::API::Registry |