[balsa: 2/3] body: Another "message/external-body" fix



commit 151f16fb631c18d34814a99eebc2d87f593ae0a7
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jul 5 12:39:00 2020 -0400

    body: Another "message/external-body" fix
    
    If a part with content-type "message/external-body" has
    access-type URL, use its URL parameter as the filename, instead of
    g_mime_part_get_filename(), so that the previous commit can work.
    
    * libbalsa/body.c (libbalsa_message_body_set_filename):
      get the "access-type" parameter; if it is non-NULL and equals "URL",
      get the "URL" parameter and use it as the part's filename; we do not
      need to verify that the content-type is "message/external-body", as the
      "access-type" parameter is NULL for any other content-type.

 ChangeLog       | 14 ++++++++++++++
 libbalsa/body.c | 19 ++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a43e4e388..93762eae9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-07-05  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       body: If a part with content-type "message/external-body" has
+       access-type URL, use its URL parameter as the filename, instead
+       of g_mime_part_get_filename(), so that the previous commit can
+       work.
+
+       * libbalsa/body.c (libbalsa_message_body_set_filename): get the
+         "access-type" parameter; if it is non-NULL and equals
+         "URL", get the "URL" parameter and use it as the part's
+         filename; we do not need to verify that the content-type is
+         "message/external-body", as the "access-type" parameter is
+         NULL for any other content-type.
+
 2020-07-05  Peter Bloomfield  <pbloomfield bellsouth net>
 
        compose-window: Attachments of type "message/external-body" must
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 5d2a80cd7..4fc1e43f2 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -135,11 +135,20 @@ libbalsa_message_body_extract_embedded_headers(GMimeMessage* msg)
 static void
 libbalsa_message_body_set_filename(LibBalsaMessageBody * body)
 {
-    if (GMIME_IS_PART(body->mime_part)) {
-       g_free(body->filename);
-       body->filename =
-           g_strdup(g_mime_part_get_filename(GMIME_PART(body->mime_part)));
-    }
+    gchar *access_type;
+    gchar *filename = NULL;
+
+    access_type = libbalsa_message_body_get_parameter(body, "access-type");
+
+    if (g_strcmp0(access_type, "URL") == 0)
+        filename = libbalsa_message_body_get_parameter(body, "URL");
+    else if (GMIME_IS_PART(body->mime_part))
+       filename = g_strdup(g_mime_part_get_filename((GMimePart *) body->mime_part));
+
+    g_free(access_type);
+
+    g_free(body->filename);
+    body->filename = filename;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]