From 26aa801342727e36b3e92c4e8b348ba4e22b6a0f Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Mon, 18 Jan 2016 16:28:48 +0100 Subject: [PATCH] Check if byte strings are properly encoded in UTF-8 --- salt/modules/zypper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index ccba713f6a..b1d4853ccf 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -125,6 +125,12 @@ def info_installed(*names, **attr): t_nfo = dict() # Translate dpkg-specific keys to a common structure for key, value in pkg_nfo.items(): + if type(value) == str: + # Check, if string is encoded in a proper UTF-8 + value_ = value.decode('UTF-8', 'ignore').encode('UTF-8', 'ignore') + if value != value_: + value = value_ + log.error('Package {0} has bad UTF-8 code in {1}: {2}'.format(pkg_name, key, value)) if key == 'source_rpm': t_nfo['source'] = value else: