From 9846cc33707d9aac2d0d52f553b1274cbded2a55 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Thu, 30 Jan 2020 15:54:27 +0100 Subject: [PATCH] Different approach to handling encoding/decoding errors --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c3d0684..36594bd 100644 --- a/main.py +++ b/main.py @@ -32,9 +32,9 @@ def get_decoded_header(value): decoded_header_items = decode_header(value) decoded_header_value = '' for item in decoded_header_items: - decoded_item = item[0].decode(item[1], 'replace') if item[1] is not None else item[0] + decoded_item = item[0].decode(item[1], 'ignore') if item[1] is not None else item[0] if isinstance(decoded_item, bytes): - decoded_item = decoded_item.decode('ascii', 'replace') + decoded_item = decoded_item.decode('ascii', 'ignore') decoded_header_value += decoded_item return decoded_header_value