From 6b7255bb80de9adeb6fec7f8f5d773101afdcfb6 Mon Sep 17 00:00:00 2001 From: "Piotr F. Mieszkowski" Date: Thu, 1 Dec 2022 22:50:16 +0100 Subject: [PATCH] =?UTF-8?q?Add=20a=C2=A0more=20sophisticated=20UTF-8=C2=A0?= =?UTF-8?q?test=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new test message to verify Lacre's behaviour when processing UTF-8 messages with text in two different scripts (latin-based and cyrillic). Also: log Content-Transfer-Encoding when logging headers is enabled. --- lacre/daemon.py | 3 ++- test/e2e.ini | 8 ++++++- test/msgin/Lorem_ipsum_ru.msg | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test/msgin/Lorem_ipsum_ru.msg diff --git a/lacre/daemon.py b/lacre/daemon.py index 49849c4..adc5921 100644 --- a/lacre/daemon.py +++ b/lacre/daemon.py @@ -68,7 +68,8 @@ class MailEncryptionProxy: def _extract_headers(self, message: email.message.Message): return { 'mime' : message.get_content_type(), - 'charsets' : message.get_charsets() + 'charsets' : message.get_charsets(), + 'cte' : message['Content-Transfer-Encoding'] } diff --git a/test/e2e.ini b/test/e2e.ini index a4bd332..ab1db5e 100644 --- a/test/e2e.ini +++ b/test/e2e.ini @@ -30,7 +30,7 @@ certs: test/certs [tests] # Number of "test-*" sections in this file, describing test cases. -cases: 11 +cases: 12 e2e_log: test/logs/e2e.log e2e_log_format: %(asctime)s %(pathname)s:%(lineno)d %(levelname)s [%(funcName)s] %(message)s e2e_log_datefmt: %Y-%m-%d %H:%M:%S @@ -102,3 +102,9 @@ descr: Non-ASCII message (ISO-8859-2; yields quoted-printable) to: carlos@disposlab in: test/msgin/nonascii.msg out: =A3=A1CZNO=A6=C6. + +[case-12] +descr: Russian, with UTF-8, producing Base64 +to: carlos@disposlab +in: test/msgin/Lorem_ipsum_ru.eml +out: 0KHQvtCy0YDQtdC80 diff --git a/test/msgin/Lorem_ipsum_ru.msg b/test/msgin/Lorem_ipsum_ru.msg new file mode 100644 index 0000000..b89d482 --- /dev/null +++ b/test/msgin/Lorem_ipsum_ru.msg @@ -0,0 +1,43 @@ +Content-Type: multipart/alternative; + boundary="------------6s7R3c0y2W8qiD7cU3iWyXcw" +Date: Wed, 23 Nov 2022 08:06:29 +0100 +MIME-Version: 1.0 +Content-Language: pl-PL +From: Sender +To: carlos@disposlab +Subject: Lorem ipsum... + +This is a multi-part message in MIME format. +--------------6s7R3c0y2W8qiD7cU3iWyXcw +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit + +Современная литература - это всемирное культурное богатство, наследие +всех людей, которые находят вдохновение в книгах. Читать - значит жить, +вникать в поток мыслей других. + +Współczesna literatura to światowe bogactwo kulturowe, dziedzictwo +wszystkich ludzi, którzy znajdują inspirację w książkach. Czytać to żyć, +zagłębiać się w przepływ myśli innych. + +--------------6s7R3c0y2W8qiD7cU3iWyXcw +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + + + + + +

Современная литература - это всемирное культурное богатство, + наследие всех людей, которые находят вдохновение в книгах. Читать + - значит жить, вникать в поток мыслей других.
+
+ Współczesna literatura to światowe bogactwo kulturowe, dziedzictwo + wszystkich ludzi, którzy znajdują inspirację w książkach. Czytać + to żyć, zagłębiać się w przepływ myśli innych.
+

+ + + +--------------6s7R3c0y2W8qiD7cU3iWyXcw--