From 8ed619687ffa908836a0e33427531efcda4d3b92 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Wed, 30 Sep 2020 12:00:05 +0200 Subject: [PATCH] ignore UnicodeDecodeError when parsing SpamAssassin response --- app/spamassassin_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/spamassassin_utils.py b/app/spamassassin_utils.py index d4b6f991..b972d1e9 100644 --- a/app/spamassassin_utils.py +++ b/app/spamassassin_utils.py @@ -74,7 +74,9 @@ class SpamAssassin(object): logging.error(first_line) return None - report_list = [s.strip() for s in body.decode("utf-8").strip().split("\n")] + report_list = [ + s.strip() for s in body.decode("utf-8", errors="ignore").strip().split("\n") + ] linebreak_num = report_list.index([s for s in report_list if "---" in s][0]) tablelists = [s for s in report_list[linebreak_num + 1 :]]