From 3c9e93228a4d611be6d50f9620a8f38598407be5 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 16 Oct 2022 00:57:19 +0300 Subject: [PATCH] view: be clearer there's no text body found There may have been an html body, but mu-view only shows a text-body; make that clearer. Add a test case for an html-only message. Fixes #2349. --- lib/message/test-mu-message.cc | 117 +++++++++++++++++++++++++++++++++ mu/mu-cmd.cc | 4 +- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/lib/message/test-mu-message.cc b/lib/message/test-mu-message.cc index 6d19488e..bcfbbf62 100644 --- a/lib/message/test-mu-message.cc +++ b/lib/message/test-mu-message.cc @@ -855,6 +855,121 @@ On Thu, Aug 04, 2022 at 05:31:39PM +0100, Robin Murphy wrote: } +static void +test_message_outlook_body() +{ + constexpr auto msgtext = +R"x(Received: from vu-ex2.activedir.vu.lt (172.16.159.219) by + vu-ex1.activedir.vu.lt (172.16.159.218) with Microsoft SMTP Server + (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9 + via Mailbox Transport; Fri, 27 May 2022 11:40:05 +0300 +Received: from vu-ex2.activedir.vu.lt (172.16.159.219) by + vu-ex2.activedir.vu.lt (172.16.159.219) with Microsoft SMTP Server + (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id + 15.2.1118.9; Fri, 27 May 2022 11:40:05 +0300 +Received: from vu-ex2.activedir.vu.lt ([172.16.159.219]) by + vu-ex2.activedir.vu.lt ([172.16.159.219]) with mapi id 15.02.1118.009; Fri, + 27 May 2022 11:40:05 +0300 +From: =?windows-1257?Q?XXXXXXXXXX= +To: +Subject: =?windows-1257?Q?Pra=F0ymas?= +Thread-Topic: =?windows-1257?Q?Pra=F0ymas?= +Thread-Index: AQHYcaRi3ejPSLxkl0uTFDto7z2OcA== +Date: Fri, 27 May 2022 11:40:05 +0300 +Message-ID: <5c2cd378af634e929a6cc69da1e66b9d@XX.vu.lt> +Accept-Language: en-US, lt-LT +Content-Language: en-US +X-MS-Has-Attach: +Content-Type: text/html; charset="windows-1257" +Content-Transfer-Encoding: quoted-printable +MIME-Version: 1.0 +X-TUID: 1vFQ9RPwwg/u + + + + + + + +
+

Laba diena visiems,

+

Trumpai.

+

D=EBl leidimo ar neleidimo ginti darb=E0: ed=EBstytojo paskyroje spaud= +=FEiate ikon=E0 "ra=F0to darbai", atidar=E6 susiraskite =E1ra=F0= +=E0 "tvirtinti / netvirtinti", pa=FEym=EBkite vien=E0 i=F0 j=F8.&= +nbsp;

+


+

+

=D0=E1 darb=E0 privalu atlikti, kad paskui nekilt=F8 problem=F8 studentu= +i =E1vedant =E1vertinim=E0.

+


+

+

Jei neleid=FEiate ginti darbo, pra=F0au informuoti mane ir komisijos sek= +retori=F8.  

+


+

+

Vis=E0 tolesn=E6 informacij=E0 atsi=F8siu artimiausiu metu (stengsiuosi = +=F0iandien vakare).

+


+

+

Pagarbiai.

+


+

+


+

+
+
+


+

+


+

+


+

+


+

+

XXXXXXXXXX

+

<= +/span>

+ +

XXXXXXXXXX

+

XXXXXXXXXX

+

XXXXXXXXXX

+


+

+


+

+
+
+
+ + +)x"; + g_test_bug("2349"); + + auto message{Message::make_from_text( + msgtext, + "/home/test/Maildir/inbox/cur/162342449279256.77777_1.evergrey:2,S")}; + g_assert_true(!!message); + + assert_equal(message->subject(), "Prašymas"); + g_assert_true(message->priority() == Priority::Normal); + + g_assert_false(!!message->body_text()); + g_assert_true(!!message->body_html()); + g_assert_cmpuint(message->body_html()->find("

Pagarbiai.

"), ==, 935); +} + + + static void test_message_fail () { @@ -898,6 +1013,8 @@ main(int argc, char* argv[]) test_message_calendar); g_test_add_func("/message/message/references", test_message_references); + g_test_add_func("/message/message/outlook-body", + test_message_outlook_body); g_test_add_func("/message/message/fail", test_message_fail); g_test_add_func("/message/message/sanitize-maildir", diff --git a/mu/mu-cmd.cc b/mu/mu-cmd.cc index 07656bce..a171389f 100644 --- a/mu/mu-cmd.cc +++ b/mu/mu-cmd.cc @@ -111,11 +111,11 @@ body_or_summary(const Message& message, const MuConfig* opts) if (!body || body->empty()) { if (any_of(message.flags() & Flags::Encrypted)) { color_maybe(MU_COLOR_CYAN); - g_print("[No body found; " + g_print("[No text body found; " "message has encrypted parts]\n"); } else { color_maybe(MU_COLOR_MAGENTA); - g_print("[No body found]\n"); + g_print("[No text body found]\n"); } color_maybe(MU_COLOR_DEFAULT); return;