mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
salt.states.reg.present: Prevent traceback when reg data is binary
This prevents a failed decode of undecodable data from resulting in a traceback by catching the exception and just using the original value in the changes dict.
This commit is contained in:
parent
7779fea7ba
commit
8cf13325ee
@ -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']:
|
||||
|
Loading…
Reference in New Issue
Block a user