Add error handling to the RPM broken strings

This commit is contained in:
Bo Maryniuk 2016-01-19 13:02:46 +01:00
parent cf0dad3a6c
commit 1d384b6abd

View File

@ -129,7 +129,7 @@ def info_installed(*names, **kwargs):
# Check, if string is encoded in a proper UTF-8 # Check, if string is encoded in a proper UTF-8
value_ = value.decode('UTF-8', 'ignore').encode('UTF-8', 'ignore') value_ = value.decode('UTF-8', 'ignore').encode('UTF-8', 'ignore')
if value != value_: if value != value_:
value = value_ value = kwargs.get('errors', 'ignore') == 'ignore' and value_ or 'N/A (broken)'
log.error('Package {0} has bad UTF-8 code in {1}: {2}'.format(pkg_name, key, value)) log.error('Package {0} has bad UTF-8 code in {1}: {2}'.format(pkg_name, key, value))
if key == 'source_rpm': if key == 'source_rpm':
t_nfo['source'] = value t_nfo['source'] = value