[PATCH] emacs: bugfix attachment content-type as mime-type handling

Mark Walters markwalters1009 at gmail.com
Tue Jul 30 09:15:00 PDT 2013


Notmuch puts attachments in as declared content-type except when the
content-type is application/octet-stream it tries to guess the type
from the filename/extension. This means that viewing a pdf (for
example) which is sent as application/octet-strem invokes the pdf
viewer rather than just offering to save the part.

Recent changes to the attachment handling (commit 1546387d) changed
(broke) this. This patch stores the calculated mime-type with the part
and changes the attachment part handlers can use it instead.
---
This seems to fix the bug for me. I am not sure I like the naming
(mime-type/content-type). Maybe it would be better to be explicit with
something like calculated-content-type but probably that should be a
more wholesale renaming.

Best wishes

Mark


 emacs/notmuch-show.el |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c4e0a99..9f47f5e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -892,6 +892,9 @@ If HIDE is non-nil then initially hide this part."
 		   (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
 	 (content-beg (point)))
 
+    ;; Store the calculated mime-type for later use (e.g. by attachment handlers).
+    (plist-put part :mime-type mime-type)
+
     (if (not hide)
         (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)
       (button-put button :notmuch-lazy-part
@@ -2055,10 +2058,10 @@ caller is responsible for killing this buffer as appropriate."
 	 (message-id (notmuch-show-get-message-id))
 	 (nth (plist-get part :id))
 	 (buf (notmuch-show-generate-part-buffer message-id nth))
-	 (content-type (plist-get part :content-type))
+	 (mime-type (plist-get part :mime-type))
 	 (filename (plist-get part :filename))
 	 (disposition (if filename `(attachment (filename . ,filename)))))
-    (mm-make-handle buf (list content-type) nil nil disposition)))
+    (mm-make-handle buf (list mime-type) nil nil disposition)))
 
 (defun notmuch-show-apply-to-current-part-handle (fn)
   "Apply FN to an mm-handle for the part containing point.
-- 
1.7.9.1



More information about the notmuch mailing list