[PATCH] emacs: bugfix attachment content-type as mime-type handling
authorMark Walters <markwalters1009@gmail.com>
Tue, 30 Jul 2013 16:15:00 +0000 (17:15 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:12 +0000 (09:56 -0800)
db/305186e420d87573c3b03196f6951752984629 [new file with mode: 0644]

diff --git a/db/305186e420d87573c3b03196f6951752984629 b/db/305186e420d87573c3b03196f6951752984629
new file mode 100644 (file)
index 0000000..095071f
--- /dev/null
@@ -0,0 +1,116 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7759C431FC0\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Jul 2013 09:15:14 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id U8p2OVj7dLnx for <notmuch@notmuchmail.org>;\r
+       Tue, 30 Jul 2013 09:15:07 -0700 (PDT)\r
+Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com\r
+ [74.125.82.48])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ C0EC5431FBF   for <notmuch@notmuchmail.org>; Tue, 30 Jul 2013 09:15:06 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f48.google.com with SMTP id f12so5579926wgh.15\r
+       for <notmuch@notmuchmail.org>; Tue, 30 Jul 2013 09:15:05 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=bcay4ULQWLHUKCBhZdxcsVLmgxszGt+VYI7h+Jg50M0=;\r
+       b=gEHAAhl7t9blskjE83GDa1uSZVyL6Eu/3nSpWRKtvxZZSjWCGN6xwJY9HVFkgfD8GN\r
+       NUkLCajt1mGMy7ZyxyuSpjb+VqFNDS/yY0fBQgTyRnbbEVVwm+mTJwCfBi5ltr0RGYX0\r
+       nNkGHQgbqUDYEfVVHdKY3NoD9uTnwMGg1Sv5PFyataf0iF/rhXwVQkfuGD9VCCqTKseO\r
+       PbfYukNsLMsjN549Ja9sV0nu+zJOJyg3EK+c4359gVnBd0laH11VLnRzyNGsEXgNSHsO\r
+       9dDyije0PgBX+ZGR1959CUbwJuf2CEFspCS4YJ5QsXswC6Jq1prWtFiJv70cpTsg6ecf\r
+       V3wg==\r
+X-Received: by 10.194.219.198 with SMTP id pq6mr47256898wjc.58.1375200905629; \r
+       Tue, 30 Jul 2013 09:15:05 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPSA id i1sm29550731wiz.6.2013.07.30.09.15.04\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Tue, 30 Jul 2013 09:15:04 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: bugfix attachment content-type as mime-type handling\r
+Date: Tue, 30 Jul 2013 17:15:00 +0100\r
+Message-Id: <1375200900-5650-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <87li4om623.fsf@qmul.ac.uk>\r
+References: <87li4om623.fsf@qmul.ac.uk>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 30 Jul 2013 16:15:14 -0000\r
+\r
+Notmuch puts attachments in as declared content-type except when the\r
+content-type is application/octet-stream it tries to guess the type\r
+from the filename/extension. This means that viewing a pdf (for\r
+example) which is sent as application/octet-strem invokes the pdf\r
+viewer rather than just offering to save the part.\r
+\r
+Recent changes to the attachment handling (commit 1546387d) changed\r
+(broke) this. This patch stores the calculated mime-type with the part\r
+and changes the attachment part handlers can use it instead.\r
+---\r
+This seems to fix the bug for me. I am not sure I like the naming\r
+(mime-type/content-type). Maybe it would be better to be explicit with\r
+something like calculated-content-type but probably that should be a\r
+more wholesale renaming.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+ emacs/notmuch-show.el |    7 +++++--\r
+ 1 files changed, 5 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index c4e0a99..9f47f5e 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -892,6 +892,9 @@ If HIDE is non-nil then initially hide this part."\r
+                  (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
+        (content-beg (point)))\r
\r
++    ;; Store the calculated mime-type for later use (e.g. by attachment handlers).\r
++    (plist-put part :mime-type mime-type)\r
++\r
+     (if (not hide)\r
+         (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
+       (button-put button :notmuch-lazy-part\r
+@@ -2055,10 +2058,10 @@ caller is responsible for killing this buffer as appropriate."\r
+        (message-id (notmuch-show-get-message-id))\r
+        (nth (plist-get part :id))\r
+        (buf (notmuch-show-generate-part-buffer message-id nth))\r
+-       (content-type (plist-get part :content-type))\r
++       (mime-type (plist-get part :mime-type))\r
+        (filename (plist-get part :filename))\r
+        (disposition (if filename `(attachment (filename . ,filename)))))\r
+-    (mm-make-handle buf (list content-type) nil nil disposition)))\r
++    (mm-make-handle buf (list mime-type) nil nil disposition)))\r
\r
+ (defun notmuch-show-apply-to-current-part-handle (fn)\r
+   "Apply FN to an mm-handle for the part containing point.\r
+-- \r
+1.7.9.1\r
+\r