1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 9290F431E64
\r
6 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:22 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id OCDgO+ODL92l for <notmuch@notmuchmail.org>;
\r
16 Mon, 21 Apr 2014 11:38:17 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id EB895431FC9
\r
22 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:03 -0700 (PDT)
\r
23 X-AuditID: 12074425-f79906d000000cf9-27-5355658a88d8
\r
24 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id D9.F3.03321.A8565535; Mon, 21 Apr 2014 14:38:02 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3LIc18g018353;
\r
31 Mon, 21 Apr 2014 14:38:01 -0400
\r
32 Received: from drake.dyndns.org
\r
33 (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
34 [216.15.114.40]) (authenticated bits=0)
\r
35 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
36 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3LIbshb029728
\r
37 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
38 Mon, 21 Apr 2014 14:38:00 -0400
\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
40 (envelope-from <amdragon@mit.edu>)
\r
41 id 1WcJ6I-0003lL-I6; Mon, 21 Apr 2014 14:37:54 -0400
\r
42 From: Austin Clements <amdragon@MIT.EDU>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 11/11] emacs: Support cid: references with shr renderer
\r
45 Date: Mon, 21 Apr 2014 14:37:48 -0400
\r
46 Message-Id: <1398105468-14317-12-git-send-email-amdragon@mit.edu>
\r
47 X-Mailer: git-send-email 1.9.1
\r
48 In-Reply-To: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
49 References: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixCmqrduVGhpssLrByuL6zZnMDowez1bd
\r
52 Yg5gjOKySUnNySxLLdK3S+DKeHD9KGPBDLGKzrd/mBsY/wh2MXJySAiYSOxoPMICYYtJXLi3
\r
53 nq2LkYtDSGA2k8Syn/OZIZyNjBJfXh1jhXDuMEk8XLecBcKZyyjxas8GRpB+NgENiW37l4PZ
\r
54 IgLSEjvvzgbq4OBgFlCT+NOlAhIWFnCXaLm0hRnEZhFQlTh8+TgTiM0r4CixZ/ZUNogz5CRO
\r
55 HpvMCmJzAsXbVr9kB7GFBBwkNuxdwzSBkX8BI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXQu9
\r
56 3MwSvdSU0k2MoLBhd1HdwTjhkNIhRgEORiUe3gKj0GAh1sSy4srcQ4ySHExKoryvooBCfEn5
\r
57 KZUZicUZ8UWlOanFhxglOJiVRHjXawLleFMSK6tSi/JhUtIcLErivG+trYKFBNITS1KzU1ML
\r
58 UotgsjIcHEoSvGkpQI2CRanpqRVpmTklCGkmDk6Q4TxAw6NAaniLCxJzizPTIfKnGBWlxHnb
\r
59 QBICIImM0jy4Xlhcv2IUB3pFmNcdpIoHmBLgul8BDWYCGvxkSwjI4JJEhJRUA+M8CwVHhy+N
\r
60 +fMmLPM+LsjKneiu++qLeZiCUlHbJ7+nbKXrDKRe9OWUCmQzruLYGB+0m1Eu2Smv6vrBwuvq
\r
61 CvzTTnQcWfqieZnkrX3OMt5FWmG1365Vu7RamLqYy0w8m7GkaI1vwMlPmyKkviVmqB6Weyx/
\r
62 rSyjqe7Igildx7f+Y1ucHPu9WYmlOCPRUIu5qDgRACHRn1/GAgAA
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Mon, 21 Apr 2014 18:38:23 -0000
\r
77 shr has really nice support for inline image rendering, but previously
\r
78 we only had the hooks for w3m cid: references.
\r
80 emacs/notmuch-show.el | 41 +++++++++++++++++++++++++++++++++--------
\r
81 1 file changed, 33 insertions(+), 8 deletions(-)
\r
83 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
84 index f758091..a489279 100644
\r
85 --- a/emacs/notmuch-show.el
\r
86 +++ b/emacs/notmuch-show.el
\r
87 @@ -745,14 +745,39 @@ (defun notmuch-show-get-mime-type-of-application/octet-stream (part)
\r
90 (defun notmuch-show-insert-part-text/html (msg part content-type nth depth button)
\r
91 - ;; text/html handler to work around bugs in renderers and our
\r
92 - ;; invisibile parts code. In particular w3m sets up a keymap which
\r
93 - ;; "leaks" outside the invisible region and causes strange effects
\r
94 - ;; in notmuch. We set mm-inline-text-html-with-w3m-keymap to nil to
\r
95 - ;; tell w3m not to set a keymap (so the normal notmuch-show-mode-map
\r
97 - (let ((mm-inline-text-html-with-w3m-keymap nil))
\r
98 - (notmuch-show-insert-part-*/* msg part content-type nth depth button)))
\r
99 + (if (eq mm-text-html-renderer 'shr)
\r
100 + ;; It's easier to drive shr ourselves than to work around the
\r
101 + ;; goofy things `mm-shr' does (like irreversibly taking over
\r
102 + ;; content ID handling).
\r
103 + (notmuch-show--insert-part-text/html-shr msg part)
\r
104 + ;; Otherwise, let message-mode do the heavy lifting
\r
106 + ;; w3m sets up a keymap which "leaks" outside the invisible region
\r
107 + ;; and causes strange effects in notmuch. We set
\r
108 + ;; mm-inline-text-html-with-w3m-keymap to nil to tell w3m not to
\r
109 + ;; set a keymap (so the normal notmuch-show-mode-map remains).
\r
110 + (let ((mm-inline-text-html-with-w3m-keymap nil))
\r
111 + (notmuch-show-insert-part-*/* msg part content-type nth depth button))))
\r
113 +(defun notmuch-show--insert-part-text/html-shr (msg part)
\r
114 + ;; Make sure shr is loaded before we start let-binding its globals
\r
116 + (let ((dom (let (process-crypto notmuch-show-process-crypto)
\r
117 + (with-temp-buffer
\r
118 + (insert (notmuch-get-bodypart-text msg part process-crypto))
\r
119 + (libxml-parse-html-region (point-min) (point-max)))))
\r
120 + (shr-content-function
\r
122 + ;; shr strips the "cid:" part of URL, but doesn't
\r
123 + ;; URL-decode it (see RFC 2392).
\r
124 + (let ((cid (url-unhex-string url)))
\r
125 + (first (notmuch-show--get-cid-content cid)))))
\r
126 + ;; Block all external images to prevent privacy leaks and
\r
127 + ;; potential attacks. FIXME: If we block an image, offer a
\r
128 + ;; button to load external images.
\r
129 + (shr-blocked-images "."))
\r
130 + (shr-insert-document dom)
\r
133 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth button)
\r
134 ;; This handler _must_ succeed - it is the handler of last resort.
\r