86c13548fd
1 OBS-URL: https://build.opensuse.org/request/show/354612 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=54
41 lines
1.5 KiB
Diff
41 lines
1.5 KiB
Diff
From 8fcc530f0473e9fcd5a7099617516a6d184b5303 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
|
|
Date: Thu, 10 Dec 2015 13:21:41 +0100
|
|
Subject: [PATCH] zypper: check package header content for valid utf-8
|
|
|
|
"salt 'system.domain.tld' pkg.info_installed --out json" can crash with
|
|
|
|
[ERROR ] An un-handled exception was caught by salt's global exception handler:
|
|
UnicodeDecodeError: 'utf8' codec can't decode byte ...
|
|
|
|
if a package name, summary, or description contains invalid UTF-8.
|
|
|
|
This patch detects such rpm header values, logs them as errors, and
|
|
replaces them with "*** Bad UTF-8 ***".
|
|
|
|
Update: drop the 'errors=' named parameter from the encode() call as it
|
|
is incompatible with Python 2.6 as used in SLE 11.
|
|
---
|
|
salt/modules/zypper.py | 5 +++++
|
|
1 file changed, 5 insertions(+)
|
|
|
|
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
|
|
index be28311ae1bd..483d63e08edc 100644
|
|
--- a/salt/modules/zypper.py
|
|
+++ b/salt/modules/zypper.py
|
|
@@ -115,6 +115,11 @@ def info_installed(*names):
|
|
t_nfo = dict()
|
|
# Translate dpkg-specific keys to a common structure
|
|
for key, value in pkg_nfo.items():
|
|
+ try:
|
|
+ value = value.encode('UTF-8', 'replace')
|
|
+ except(UnicodeDecodeError):
|
|
+ log.error('Package {0} has bad UTF-8 code in {1}: {2}'.format(pkg_name, key, value))
|
|
+ value = '*** Bad UTF-8 ***'
|
|
if key == 'source_rpm':
|
|
t_nfo['source'] = value
|
|
else:
|
|
--
|
|
2.6.3
|
|
|