From ea0cf58bf1a7564c727423c8a18e799b22b749b5 Mon Sep 17 00:00:00 2001 From: ptav <7433752+ptav@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:03:59 +0100 Subject: [PATCH 1/2] Partially handles iso-8859-8-i encoding Casts it to iso-8859-8 but message will still create challenges downstream where it gets treated as pure ASCII while generating a warning --- django_mailbox/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django_mailbox/utils.py b/django_mailbox/utils.py index 58052115..de624a83 100644 --- a/django_mailbox/utils.py +++ b/django_mailbox/utils.py @@ -78,6 +78,8 @@ def _decode(value, encoding): return value if not encoding or encoding == 'unknown-8bit': encoding = default_charset + elif encoding == 'iso-8859-8-i': + encoding = 'iso-8859-8' return value.decode(encoding, 'replace') try: From 6f2113a064d262abd43b5aaeeff633164e34b769 Mon Sep 17 00:00:00 2001 From: ptav <7433752+ptav@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:19:30 +0100 Subject: [PATCH 2/2] Cast iso-8859-8-i down to iso-8859-8 Attempt to do a better job than simply treating the email as ASCII --- django_mailbox/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django_mailbox/models.py b/django_mailbox/models.py index 4c76dc55..8ab6ce11 100644 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -374,6 +374,12 @@ def _get_dehydrated_message(self, msg, record): content_charset = msg.get_content_charset() if not content_charset: content_charset = 'ascii' + elif content_charset == 'iso-8859-8-i': + content_charset = 'iso-8859-8' + logger.warning( + "Unhandled encoding %s; interpreting as iso-8859-8", + content_charset + ) try: # Make sure that the payload can be properly decoded in the # defined charset, if it can't, let's mash some things