Merge pull request #46000 from terminalmage/issue45910

salt.states.reg.present: Prevent traceback when reg data is binary
This commit is contained in:
Nicole Thomas 2018-02-14 10:55:41 -05:00 committed by GitHub
commit 8a60635da0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -192,9 +192,14 @@ def present(name,
salt.utils.to_unicode(name, 'utf-8'))
return ret
try:
vdata_decoded = salt.utils.to_unicode(vdata, 'utf-8')
except UnicodeDecodeError:
# vdata contains binary data that can't be decoded
vdata_decoded = vdata
add_change = {'Key': r'{0}\{1}'.format(hive, key),
'Entry': u'{0}'.format(salt.utils.to_unicode(vname, 'utf-8') if vname else u'(Default)'),
'Value': salt.utils.to_unicode(vdata, 'utf-8')}
'Value': vdata_decoded}
# Check for test option
if __opts__['test']: