From a25464326817fa85c5be31abc7180d6552e5b16c Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sun, 15 Jan 2023 17:37:34 +0100 Subject: [PATCH] armbian-next: `patching`: avoid mangling valid utf-8 from mbox'es --- lib/tools/common/patching_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tools/common/patching_utils.py b/lib/tools/common/patching_utils.py index c102d2f6d1..074732364e 100644 --- a/lib/tools/common/patching_utils.py +++ b/lib/tools/common/patching_utils.py @@ -173,7 +173,13 @@ class PatchFileInDir: patches: list[PatchInPatchFile] = [] msg: mailbox.mboxMessage for msg in mbox: - patch: str = msg.get_payload() + patch: str + try: + patch = msg.get_payload(decode=True).decode("utf-8") + except UnicodeDecodeError as e: + log.error(f"Error decoding UTF-8 mbox payload in file {self.full_file_path()}(:{counter}): {e}") + patch = msg.get_payload() # this will mangle valid utf-8 + # split the patch itself and the description from the payload desc, patch_contents = self.split_description_and_patch(patch) if len(patch_contents) == 0: