From 93eab82c6026e9c12d145f41cd4423ff0d892884 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 31 Jul 2013 19:39:05 +0100 Subject: [PATCH] [PATCH v2] emacs: bugfix attachment content-type as mime-type handling --- 85/a1890e1e10839fbb4c3abde73b34b94028894d | 119 ++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 85/a1890e1e10839fbb4c3abde73b34b94028894d diff --git a/85/a1890e1e10839fbb4c3abde73b34b94028894d b/85/a1890e1e10839fbb4c3abde73b34b94028894d new file mode 100644 index 000000000..9c49810a4 --- /dev/null +++ b/85/a1890e1e10839fbb4c3abde73b34b94028894d @@ -0,0 +1,119 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 8F281431FC0 + for ; Wed, 31 Jul 2013 11:39:26 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id RKSg4g+qmZU2 for ; + Wed, 31 Jul 2013 11:39:19 -0700 (PDT) +Received: from mail-we0-f172.google.com (mail-we0-f172.google.com + [74.125.82.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D15D3431FBF + for ; Wed, 31 Jul 2013 11:39:18 -0700 (PDT) +Received: by mail-we0-f172.google.com with SMTP id t61so945022wes.31 + for ; Wed, 31 Jul 2013 11:39:16 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=F6YaVJyFKGrwFVqM6vL3c/UQZaCw/ykxLo8nl1wCiw8=; + b=Egvf8eH0qbTuADp4UoOTzgBXoU5zsnVuJHawz0JXHHNnF4GUgGACxCyEmewGQHIcju + TuzXA2nrbWbpG7v03w5E28WuPYVlAaxk9qLWm2fHf4GGA5woRk3hRqToyEDYTSno5zj5 + +JDWMlymQAvP7l6gW0O1nVSCRVJqUFYM1JVRfF1uSgHls0M1KPD66l+hrQjSNe/r8BkK + xY/q+ZSaywmf4YkLBbXw2c1ErifSSuRDJuWHyb5f/yARFtzI9k7Kg84otwXdAZPBGxDR + gkSiMVA7KxLFKecD48ASIGEAziQrsP1QIu8HcyMnAA8rhEndaFepkDw5dILfqgAtEpl9 + 7tPA== +X-Received: by 10.180.185.97 with SMTP id fb1mr197662wic.61.1375295955157; + Wed, 31 Jul 2013 11:39:15 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id u9sm29541wif.6.2013.07.31.11.39.13 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Wed, 31 Jul 2013 11:39:14 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: bugfix attachment content-type as mime-type + handling +Date: Wed, 31 Jul 2013 19:39:05 +0100 +Message-Id: <1375295945-30006-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <20130731022529.GU2214@mit.edu> +References: <20130731022529.GU2214@mit.edu> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 31 Jul 2013 18:39:26 -0000 + +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 is the same as v1 except that it uses the name computed-type +rather than mime-type for the computed mime type. + +We may want to change some of the other uses of the mime-type variable +name too but the view on irc was that that could wait. + +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..82b70ba 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 computed mime-type for later use (e.g. by attachment handlers). ++ (plist-put part :computed-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)) ++ (computed-type (plist-get part :computed-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 computed-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 + -- 2.26.2