From 02fb5aafe30ff40b252a27eda4f189c3e4911c70 Mon Sep 17 00:00:00 2001 From: "Mariusz B. / mgeeky" Date: Mon, 13 Dec 2021 14:54:20 +0100 Subject: [PATCH] Fix that hopefully addresses issues/3 --- decode-spam-headers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/decode-spam-headers.py b/decode-spam-headers.py index 2c2b51f..926978f 100644 --- a/decode-spam-headers.py +++ b/decode-spam-headers.py @@ -1770,6 +1770,7 @@ class SMTPHeadersAnalysis: @staticmethod def safeBase64Decode(value): enc = False + if type(value) == str: enc = True value = value.encode() @@ -1777,10 +1778,13 @@ class SMTPHeadersAnalysis: try: out = base64.b64decode(value) except: - out = base64.b64decode(value + b'=' * (-len(value) % 4)) + try: + out = base64.b64decode(value + b'=' * (-len(value) % 4)) + except: + out = value if enc: - out = out.decode() + out = out.decode(errors = 'ignore') return out