Re: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
[notmuch-archives.git] / 3c / 77208ca6189ef8d191ddf8379756233f3d7f44
1 Return-Path: <tbielawa@redhat.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 BF6EE431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 17:12:27 -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: -4.99\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-4.99 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_HI=-5, T_MIME_NO_TEXT=0.01] 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 b1MhqliM2LFb for <notmuch@notmuchmail.org>;\r
16         Sat,  3 Mar 2012 17:12:26 -0800 (PST)\r
17 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\r
18         by olra.theworths.org (Postfix) with ESMTP id 8BE55431FAE\r
19         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 17:12:26 -0800 (PST)\r
20 Received: from int-mx10.intmail.prod.int.phx2.redhat.com\r
21         (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])\r
22         by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q241CLMq011042\r
23         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);\r
24         Sat, 3 Mar 2012 20:12:22 -0500\r
25 Received: from dehydrator.rdu.redhat.com (spatula.rdu.redhat.com\r
26         [10.11.95.223])\r
27         by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP\r
28         id q241CLP7023182\r
29         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\r
30         Sat, 3 Mar 2012 20:12:21 -0500\r
31 Received: from dehydrator.spatula.rdu.redhat.com (localhost [127.0.0.1])\r
32         by dehydrator.rdu.redhat.com (Postfix) with ESMTP id BC7E123347;\r
33         Sat,  3 Mar 2012 20:12:20 -0500 (EST)\r
34 Received: (from tbielawa@localhost)\r
35         by dehydrator.spatula.rdu.redhat.com (8.14.5/8.14.5/Submit) id\r
36         q241CKBk027928; Sat, 3 Mar 2012 20:12:20 -0500\r
37 X-Authentication-Warning: dehydrator.spatula.rdu.redhat.com: tbielawa set\r
38         sender to tbielawa@redhat.com using -f\r
39 From: Tim Bielawa <tbielawa@redhat.com>\r
40 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
41 Subject: Re: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled\r
42 In-Reply-To: <87ty25fe9u.fsf@nikula.org>\r
43 References: <1330812262-28272-1-git-send-email-tbielawa@redhat.com>\r
44         <87ty25fe9u.fsf@nikula.org>\r
45 User-Agent: Notmuch/0.12~rc1 (http://notmuchmail.org) Emacs/23.3.1\r
46         (x86_64-redhat-linux-gnu)\r
47 Date: Sat, 03 Mar 2012 20:12:12 -0500\r
48 Message-ID: <87fwdptbir.fsf@dehydrator.spatula.rdu.redhat.com>\r
49 MIME-Version: 1.0\r
50 Content-Type: multipart/signed; boundary="=-=-=";\r
51         micalg=pgp-sha1; protocol="application/pgp-signature"\r
52 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Sun, 04 Mar 2012 01:12:27 -0000\r
66 \r
67 --=-=-=\r
68 Content-Transfer-Encoding: quoted-printable\r
69 \r
70 On Sun, 04 Mar 2012 01:36:29 +0200, Jani Nikula <jani@nikula.org> wrote:\r
71 > On Sat,  3 Mar 2012 17:04:22 -0500, Tim Bielawa <tbielawa@redhat.com> wro=\r
72 te:\r
73 > > The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks\r
74 > > automatic signing in replies. When replies are mml-quoted and signing\r
75 > > is enabled by default the "<#part sign=3Dpgpmime>" string will appear on\r
76 > > line 1. This will be consumed during the application of the\r
77 > > mml-quote-region function and transform into the inert string\r
78 > > "<#!part sign=3Dpgpmime>". The result is that responses will no longer\r
79 > > be signed by default.\r
80 > >=20\r
81 > > This fix moves the point forward one line before applying the quoting\r
82 > > function.\r
83 > >=20\r
84 > > Consideration: Clients not signing mail by default. The first line of\r
85 > > their responses would be skipped when the quoting function is\r
86 > > applied. This string takes this general form:\r
87 > >=20\r
88 > >     On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org=\r
89  wrote:\r
90 > >=20\r
91 > > Because the string is generated by notmuch I don't believe this fix\r
92 > > introduces the possibility for malicious mml commands being omitted\r
93 > > from the quoting.\r
94 >=20\r
95 > Hmm, would it work to mml quote the reply *before* extracting it from\r
96 > the temp buffer, like below? It would handle not mml quoting the user's\r
97 > signature too. Completely untested...\r
98 >=20\r
99 > BR,\r
100 > Jani.\r
101 >=20\r
102 >=20\r
103 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
104 > index 4be7c13..13244eb 100644\r
105 > --- a/emacs/notmuch-mua.el\r
106 > +++ b/emacs/notmuch-mua.el\r
107 > @@ -95,6 +95,9 @@ list."\r
108 >             (goto-char (point-min))\r
109 >             (setq headers (mail-header-extract)))))\r
110 >        (forward-line 1)\r
111 > +      ;; Original message may contain (malicious) MML tags. We must\r
112 > +      ;; properly quote them in the reply.\r
113 > +      (mml-quote-region (point) (point-max))\r
114 >        (setq body (buffer-substring (point) (point-max))))\r
115 >      ;; If sender is non-nil, set the From: header to its value.\r
116 >      (when sender\r
117 > @@ -116,12 +119,7 @@ list."\r
118 >      (push-mark))\r
119 >    (set-buffer-modified-p nil)\r
120 >=20=20\r
121 > -  (message-goto-body)\r
122 > -  ;; Original message may contain (malicious) MML tags.  We must\r
123 > -  ;; properly quote them in the reply.  Note that using `point-max'\r
124 > -  ;; instead of `mark' here is wrong.  The buffer may include user's\r
125 > -  ;; signature which should not be MML-quoted.\r
126 > -  (mml-quote-region (point) (mark)))\r
127 > +  (message-goto-body))\r
128 >=20=20\r
129 >  (defun notmuch-mua-forward-message ()\r
130 >    (message-forward)\r
131 \r
132 Works great. Passes unit tests. Definitely a better approach than the\r
133 original patch.\r
134 \r
135 > Notmuch test suite complete.\r
136 > All 381 tests behaved as expected (2 expected failures).\r
137 \r
138 +1 from me (this message replied to and signed using the new patch)\r
139 \r
140 =2D-=20\r
141 Tim Bielawa\r
142 \r
143 --=-=-=\r
144 Content-Type: application/pgp-signature\r
145 \r
146 -----BEGIN PGP SIGNATURE-----\r
147 \r
148 iEUEARECAAYFAk9SwWwACgkQrQXnXgMzrjeIUgCXe6PNcE8pXqOctSHHM05jKmNC\r
149 iACgwdPsXMHAFnwZiI91vwTIn7/2CQA=\r
150 =6TcP\r
151 -----END PGP SIGNATURE-----\r
152 --=-=-=--\r