armbian-next: patching: avoid mangling valid utf-8 from mbox'es

This commit is contained in:
Ricardo Pardini 2023-01-15 17:37:34 +01:00
parent 7096cf70d3
commit a254643268
No known key found for this signature in database
GPG Key ID: 3D38CA12A66C5D02

View File

@ -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: