From 0543b8addcdfc0220aae0b789d6beb44dbf3b6e7 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Mon, 27 Apr 2020 12:35:24 +0200 Subject: [PATCH] mailman: cope with mails containing broken unicode See https://pagure.io/fedora-infrastructure/issue/8824 for details. This enables the hotfix on staging only to enable testing. Signed-off-by: Nils Philippsen --- .../mailman3-broken-unicode-emails.patch | 19 +++++++++++++++++++ roles/mailman/tasks/main.yml | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 files/hotfix/mailman3/mailman3-broken-unicode-emails.patch diff --git a/files/hotfix/mailman3/mailman3-broken-unicode-emails.patch b/files/hotfix/mailman3/mailman3-broken-unicode-emails.patch new file mode 100644 index 0000000000..3065157385 --- /dev/null +++ b/files/hotfix/mailman3/mailman3-broken-unicode-emails.patch @@ -0,0 +1,19 @@ +--- a/src/mailman/email/message.py ++++ b/src/mailman/email/message.py +@@ -47,6 +47,16 @@ class Message(email.message.Message): + def __setstate__(self, values): + self.__dict__ = values + ++ def as_string(self): ++ # Work around for https://bugs.python.org/issue27321 and ++ # https://bugs.python.org/issue32330. ++ try: ++ value = email.message.Message.as_string(self) ++ except (KeyError, UnicodeEncodeError): ++ value = email.message.Message.as_bytes(self).decode( ++ 'ascii', 'replace') ++ return value ++ + @property + def sender(self): + """The address considered to be the author of the email. diff --git a/roles/mailman/tasks/main.yml b/roles/mailman/tasks/main.yml index 2109fea977..38b28162d5 100644 --- a/roles/mailman/tasks/main.yml +++ b/roles/mailman/tasks/main.yml @@ -155,6 +155,16 @@ - packages - mailman +## install hotfix for e-mails containing broken unicode +## see issue https://pagure.io/fedora-infrastructure/issue/8824 +## see upstream merge request https://gitlab.com/mailman/mailman/-/merge_requests/350 +- name: hotfix - let mailman cope with e-mails containing broken unicode + patch: src=files/hotfix/mailman3/mailman3-broken-unicode-emails.patch dest=/usr/lib/python3.4/site-packages/mailman/email/message.py + when: env == "staging" + tags: + - mailman + - hotfix + - patches # # Initialize mailman (must be done after settings up the DBs)