From 946ee144ab08c4c0d12896541eb6ed7764cfd3c8 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Thu, 5 Aug 2021 14:25:56 -0400 Subject: Handle decoding incorrectly encoded headers Sometimes the encoding indicated in the header lies and it's not actualy that codepage at all. When that happens, just replace errors and continue. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b4/__init__.py b/b4/__init__.py index 745485e..483173c 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1278,7 +1278,7 @@ class LoreMessage: if hcs is None: hcs = 'utf-8' try: - decoded += hstr.decode(hcs) + decoded += hstr.decode(hcs, errors='replace') except LookupError: # Try as utf-u decoded += hstr.decode('utf-8', errors='replace') -- cgit v1.2.3