From 3cf96899efefc535e56ffbc8ad4e25d0d66cb461 Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 15 Dec 2015 07:21:26 +0200 Subject: [PATCH] mu: decode mailing-list headers MIME-decode mailing list headers, too. Also add a unit test. This fixes issue #728. --- lib/mu-msg.c | 14 +++++++++++++- lib/tests/test-mu-msg.c | 12 ++++++------ lib/tests/testdir4/1252168370_3.14675.cthulhu!2,S | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/mu-msg.c b/lib/mu-msg.c index ccba50e3..ef8951ab 100644 --- a/lib/mu-msg.c +++ b/lib/mu-msg.c @@ -376,8 +376,20 @@ mu_msg_get_msgid (MuMsg *self) const char* mu_msg_get_mailing_list (MuMsg *self) { + const char *ml; + char *decml; + g_return_val_if_fail (self, NULL); - return get_str_field (self, MU_MSG_FIELD_ID_MAILING_LIST); + + ml = get_str_field (self, MU_MSG_FIELD_ID_MAILING_LIST); + if (!ml) + return NULL; + + decml = g_mime_utils_header_decode_text (ml); + if (!decml) + return NULL; + + return free_later_str (self, decml); } diff --git a/lib/tests/test-mu-msg.c b/lib/tests/test-mu-msg.c index 90416c2a..cca2ba45 100644 --- a/lib/tests/test-mu-msg.c +++ b/lib/tests/test-mu-msg.c @@ -334,8 +334,9 @@ test_mu_msg_references (void) static void test_mu_msg_references_dups (void) { - MuMsg *msg; - const GSList *refs; + MuMsg *msg; + const GSList *refs; + const char *mlist; msg = get_msg (MU_TESTMAILDIR4 "/1252168370_3.14675.cthulhu!2,S"); refs = mu_msg_get_references(msg); @@ -363,6 +364,9 @@ test_mu_msg_references_dups (void) "20051211184308.GB13513@gauss.org"); refs = g_slist_next (refs); + mlist = mu_msg_get_mailing_list (msg); + g_assert_cmpstr (mlist ,==, "Example of List Id"); + mu_msg_unref (msg); } @@ -405,10 +409,6 @@ test_mu_msg_references_many (void) mu_msg_unref (msg); } - - - - static void test_mu_msg_tags (void) { diff --git a/lib/tests/testdir4/1252168370_3.14675.cthulhu!2,S b/lib/tests/testdir4/1252168370_3.14675.cthulhu!2,S index 4fad7062..1e69622a 100644 --- a/lib/tests/testdir4/1252168370_3.14675.cthulhu!2,S +++ b/lib/tests/testdir4/1252168370_3.14675.cthulhu!2,S @@ -9,6 +9,7 @@ User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010) X-Accept-Language: nl-NL, nl, en MIME-Version: 1.0 To: dfgh@floppydisk.nl +List-Id: =?utf-8?q?Example_of_List_Id?= Subject: Re: xyz References: <439C1136.90504@euler.org> <4399DD94.5070309@euler.org> <20051209233303.GA13812@gauss.org> <439B41ED.2080402@euler.org> <4399DD94.5070309@euler.org> <20051209233303.GA13812@gauss.org> <439A1E03.3090604@euler.org> <20051211184308.GB13513@gauss.org> In-Reply-To: <20051211184308.GB13513@gauss.org>