Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 25 / 036971bfea6ba8b51f20eeb97981d418df775d
1 Return-Path: <jinwoo68@gmail.com>\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 749A5431FC2\r
6         for <notmuch@notmuchmail.org>; Mon,  2 Feb 2015 10:55:54 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.639\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.639 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         DNS_FROM_AHBL_RHSBL=2.438, FREEMAIL_ENVFROM_END_DIGIT=1,\r
14         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id Y3rK8oT2HJi6 for <notmuch@notmuchmail.org>;\r
18         Mon,  2 Feb 2015 10:55:51 -0800 (PST)\r
19 Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com\r
20         [209.85.223.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id 35F16431FC0\r
23         for <notmuch@notmuchmail.org>; Mon,  2 Feb 2015 10:55:51 -0800 (PST)\r
24 Received: by mail-ie0-f175.google.com with SMTP id ar1so19670950iec.6\r
25         for <notmuch@notmuchmail.org>; Mon, 02 Feb 2015 10:55:49 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id;\r
28         bh=TCQXNR9BlHS9b8+kXqPyopoK0NJOeZDADPwJmGJIeFs=;\r
29         b=lYXmiKlYL5GDWMxNWa7G7jJPUtETmSBJzXKmCbASlK8IdYIu8QLYtGB1VCmKfxjrFd\r
30         DKHziCiZ8eRx5sQ23Wp1CElCmHBbxfmxvCRURsjdSNTy/DupRbyHDxf1fWXQ+UbkBbSN\r
31         dkHhWSMx8XeKTlfYSfElG8SqexZWqAJJjAnX6gf2oGfKarQVDIVAihNcltcLo14NoS20\r
32         WsUIbOzYwccHRs0byYpkRgQfG6SZIkEreCJR0fGqCKfDjtodddkvISFTbgtmgHFdyqAR\r
33         qEhPdQvIrrbZPb6QwSX6CmuInRarPtMijG7CxtsS+BeCItIBtJN9hO4FGwO2+auG98yM\r
34         MU2w==\r
35 X-Received: by 10.50.111.168 with SMTP id ij8mr13465072igb.43.1422903348719;\r
36         Mon, 02 Feb 2015 10:55:48 -0800 (PST)\r
37 Received: from jinwoo-macbookair.roam.corp.google.com.com ([172.19.60.210])\r
38         by mx.google.com with ESMTPSA id j77sm344578ioj.30.2015.02.02.10.55.47\r
39         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\r
40         Mon, 02 Feb 2015 10:55:47 -0800 (PST)\r
41 From: Jinwoo Lee <jinwoo68@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] emacs: Add a defcustom that specifies regexp for blocked\r
44         remote images.\r
45 Date: Mon,  2 Feb 2015 10:54:06 -0800\r
46 Message-Id: <1422903246-8621-1-git-send-email-jinwoo68@gmail.com>\r
47 X-Mailer: git-send-email 2.2.2\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Mon, 02 Feb 2015 18:55:54 -0000\r
61 \r
62 It's default value is ".", meaning all remote images will be blocked\r
63 by default.\r
64 \r
65 ---\r
66 Addressed review comments.\r
67 ---\r
68  emacs/notmuch-show.el | 27 +++++++++++++++++++--------\r
69  1 file changed, 19 insertions(+), 8 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
72 index 66350d4..5d939bb 100644\r
73 --- a/emacs/notmuch-show.el\r
74 +++ b/emacs/notmuch-show.el\r
75 @@ -136,6 +136,13 @@ indentation."\r
76    :type 'boolean\r
77    :group 'notmuch-show)\r
78  \r
79 +;; By default, block all external images to prevent privacy leaks and\r
80 +;; potential attacks.\r
81 +(defcustom notmuch-show-text/html-blocked-images "."\r
82 +  "Remote images that have URLs matching this regexp will be blocked."\r
83 +  :type '(choice (const nil) regexp)\r
84 +  :group 'notmuch-show)\r
85 +\r
86  (defvar notmuch-show-thread-id nil)\r
87  (make-variable-buffer-local 'notmuch-show-thread-id)\r
88  (put 'notmuch-show-thread-id 'permanent-local t)\r
89 @@ -771,14 +778,21 @@ will return nil if the CID is unknown or cannot be retrieved."\r
90        ;; It's easier to drive shr ourselves than to work around the\r
91        ;; goofy things `mm-shr' does (like irreversibly taking over\r
92        ;; content ID handling).\r
93 -      (notmuch-show--insert-part-text/html-shr msg part)\r
94 +\r
95 +      ;; FIXME: If we block an image, offer a button to load external\r
96 +      ;; images.\r
97 +      (let ((shr-blocked-images notmuch-show-text/html-blocked-images))\r
98 +       (notmuch-show--insert-part-text/html-shr msg part))\r
99      ;; Otherwise, let message-mode do the heavy lifting\r
100      ;;\r
101      ;; w3m sets up a keymap which "leaks" outside the invisible region\r
102      ;; and causes strange effects in notmuch. We set\r
103      ;; mm-inline-text-html-with-w3m-keymap to nil to tell w3m not to\r
104      ;; set a keymap (so the normal notmuch-show-mode-map remains).\r
105 -    (let ((mm-inline-text-html-with-w3m-keymap nil))\r
106 +    (let ((mm-inline-text-html-with-w3m-keymap nil)\r
107 +         ;; FIXME: If we block an image, offer a button to load external\r
108 +         ;; images.\r
109 +         (gnus-blocked-images notmuch-show-text/html-blocked-images))\r
110        (notmuch-show-insert-part-*/* msg part content-type nth depth button))))\r
111  \r
112  ;; These functions are used by notmuch-show--insert-part-text/html-shr\r
113 @@ -797,17 +811,14 @@ will return nil if the CID is unknown or cannot be retrieved."\r
114            ;; shr strips the "cid:" part of URL, but doesn't\r
115            ;; URL-decode it (see RFC 2392).\r
116            (let ((cid (url-unhex-string url)))\r
117 -            (first (notmuch-show--get-cid-content cid)))))\r
118 -       ;; Block all external images to prevent privacy leaks and\r
119 -       ;; potential attacks.  FIXME: If we block an image, offer a\r
120 -       ;; button to load external images.\r
121 -       (shr-blocked-images "."))\r
122 +            (first (notmuch-show--get-cid-content cid))))))\r
123      (shr-insert-document dom)\r
124      t))\r
125  \r
126  (defun notmuch-show-insert-part-*/* (msg part content-type nth depth button)\r
127    ;; This handler _must_ succeed - it is the handler of last resort.\r
128 -  (notmuch-mm-display-part-inline msg part content-type notmuch-show-process-crypto)\r
129 +  (notmuch-mm-display-part-inline msg part content-type\r
130 +                                 notmuch-show-process-crypto)\r
131    t)\r
132  \r
133  ;; Functions for determining how to handle MIME parts.\r
134 -- \r
135 2.2.2\r
136 \r