[PATCH] MIME: Output the filename of a part whatever the declared disposition.

David Edmondson dme at dme.org
Mon Nov 22 03:36:47 PST 2010


Some user agents create MIME parts that are generally not rendered
inline by the emacs user interface (for example application/pdf) yet
set the disposition for the part to 'inline'. If the user wishes to
save such parts it is convenient to be prompted with the filename used
for the attachment by the sender, should it be present. To allow this,
output the filename for all MIME parts if it is known irrespective of
the declared disposition.
---
 notmuch-show.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index ef421ec..f8e37c5 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -423,7 +423,7 @@ static void
 format_part_json (GMimeObject *part, int *part_count)
 {
     GMimeContentType *content_type;
-    GMimeContentDisposition *disposition;
+    const char *filename;
     void *ctx = talloc_new (NULL);
     GMimeStream *stream_memory = g_mime_stream_mem_new ();
     GByteArray *part_content;
@@ -437,14 +437,9 @@ format_part_json (GMimeObject *part, int *part_count)
 	    *part_count,
 	    json_quote_str (ctx, g_mime_content_type_to_string (content_type)));
 
-    disposition = g_mime_object_get_content_disposition (part);
-    if (disposition &&
-	strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
-    {
-	const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-
+    filename = g_mime_part_get_filename (GMIME_PART (part));
+    if (filename != NULL)
 	printf (", \"filename\": %s", json_quote_str (ctx, filename));
-    }
 
     if (g_mime_content_type_is_type (content_type, "text", "*") &&
 	!g_mime_content_type_is_type (content_type, "text", "html"))
-- 
1.7.2.3



More information about the notmuch mailing list