Different approach to handling encoding/decoding errors

This commit is contained in:
Jan Philipp Timme 2020-01-30 15:54:27 +01:00
parent 0aa8dbb89c
commit 9846cc3370
1 changed files with 2 additions and 2 deletions

View File

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