From 93bdd167241be7a0ace51ba7b19bdc97b9494cc8 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jun 27 2022 15:49:49 +0000 Subject: Fix wrong encoding in changelog entries Relates: https://pagure.io/koji/issue/3412 --- diff --git a/koji/__init__.py b/koji/__init__.py index 462e141..55f9c43 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -3541,9 +3541,11 @@ if six.PY3: def removeNonprintable(value): # expects raw-encoded string, not unicode if six.PY2: - return value.translate(None, NONPRINTABLE_CHARS) + value = value.translate(None, NONPRINTABLE_CHARS) else: - return value.translate(NONPRINTABLE_CHARS_TABLE) + value = value.translate(NONPRINTABLE_CHARS_TABLE) + # remove broken unicode chars (some changelogs, etc.) + return value.encode('utf-8', errors='replace').decode() def _fix_print(value):