Fix reg.py to only convert text types to unicode

This commit is contained in:
twangboy 2018-01-23 10:51:45 -07:00
parent 3579534ea5
commit 0e41535cdb
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
2 changed files with 6 additions and 3 deletions

View file

@ -2750,7 +2750,7 @@ def shell_info(shell, list_modules=False):
'Software\\Microsoft\\PowerShell\\{0}'.format(reg_ver),
'Install')
if install_data.get('vtype') == 'REG_DWORD' and \
install_data.get('vdata') == salt.utils.to_unicode(1, 'mbcs'):
install_data.get('vdata') == 1:
details = __salt__['reg.list_values'](
'HKEY_LOCAL_MACHINE',
'Software\\Microsoft\\PowerShell\\{0}\\'

View file

@ -372,11 +372,14 @@ def read_value(hive, key, vname=None, use_32bit_registry=False):
# RegQueryValueEx returns and accepts unicode data
vdata, vtype = win32api.RegQueryValueEx(handle, local_vname)
if vdata or vdata in [0, '']:
# Only convert text types to unicode
ret['vtype'] = registry.vtype_reverse[vtype]
if vtype == 7:
if vtype == win32con.REG_MULTI_SZ:
ret['vdata'] = [_to_mbcs(i) for i in vdata]
else:
elif vtype in [win32con.REG_SZ, win32con.REG_EXPAND_SZ]:
ret['vdata'] = _to_mbcs(vdata)
else:
ret['vdata'] = vdata
else:
ret['comment'] = 'Empty Value'
except WindowsError: # pylint: disable=E0602