1 Return-Path: <schnouki@schnouki.net>
\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 297A9431FD2
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 04:52:01 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 2tzepF5s75ha for <notmuch@notmuchmail.org>;
\r
17 Wed, 25 Jan 2012 04:52:00 -0800 (PST)
\r
18 Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])
\r
19 by olra.theworths.org (Postfix) with ESMTP id EBFCB431FBC
\r
20 for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 04:51:59 -0800 (PST)
\r
21 Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])
\r
22 by ks3536.kimsufi.com (Postfix) with ESMTPSA id 0B3836C000A;
\r
23 Wed, 25 Jan 2012 13:50:42 +0100 (CET)
\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;
\r
25 s=key-schnouki; t=1327495842;
\r
26 bh=xa5DlQNUHDVFHqovHCFu7uZH3G02tzgSrBxyzkit+Y8=;
\r
27 h=From:To:Subject:In-Reply-To:References:Date:Message-ID:
\r
28 MIME-Version:Content-Type;
\r
29 b=FWUPb3gcJM+hFMpgylHDUzaoW2USS6g3mTc587moXnLVRy7jYdPkLtNBWsOf60YQB
\r
30 A3DVVGXjRCM0dUJh5He8bqNQF1iUyDmFaMyDaqbtkUFJE5cO6GYG/JkLzLrWpkWIjG
\r
31 yeW6zGXJDLkjrWPgyq2pH9fidPVAXKC3JlI/+p7Q=
\r
32 From: Thomas Jost <schnouki@schnouki.net>
\r
33 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH 1/2] emacs: Avoid `mail-header-parse-address' in
\r
35 `notmuch-show-clean-address'.
\r
36 In-Reply-To: <1327491904-28416-2-git-send-email-dme@dme.org>
\r
37 References: <1327491904-28416-1-git-send-email-dme@dme.org>
\r
38 <1327491904-28416-2-git-send-email-dme@dme.org>
\r
39 User-Agent: Notmuch/0.11+132~gf915e3a (http://notmuchmail.org) Emacs/24.0.92.1
\r
40 (x86_64-unknown-linux-gnu)
\r
41 Date: Wed, 25 Jan 2012 13:51:46 +0100
\r
42 Message-ID: <878vkwc5ct.fsf@thor.loria.fr>
\r
44 Content-Type: multipart/signed; boundary="=-=-=";
\r
45 micalg=pgp-sha1; protocol="application/pgp-signature"
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Wed, 25 Jan 2012 12:52:01 -0000
\r
61 Content-Type: text/plain
\r
62 Content-Transfer-Encoding: quoted-printable
\r
64 On Wed, 25 Jan 2012 11:45:03 +0000, David Edmondson <dme@dme.org> wrote:
\r
65 > `mail-header-parse-address' expects un-decoded mailbox parts, which is
\r
66 > not what we have at this point. Replace it with simple string
\r
69 > Mark the corresponding test as no longer broken.
\r
71 > Minor whitespace cleanup.
\r
73 > emacs/notmuch-show.el | 50 ++++++++++++++++++++++++++++------=
\r
75 > test/emacs-address-cleaning.sh | 1 -
\r
76 > 2 files changed, 36 insertions(+), 15 deletions(-)
\r
78 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
79 > index e6a5b31..1fd2524 100644
\r
80 > --- a/emacs/notmuch-show.el
\r
81 > +++ b/emacs/notmuch-show.el
\r
82 > @@ -289,21 +289,43 @@ operation on the contents of the current buffer."
\r
83 > "Try to clean a single email ADDRESS for display. Return
\r
84 > unchanged ADDRESS if parsing fails."
\r
85 > (condition-case nil
\r
86 > - (let* ((parsed (mail-header-parse-address address))
\r
87 > - (address (car parsed))
\r
88 > - (name (cdr parsed)))
\r
89 > - ;; Remove double quotes. They might be required during transport,
\r
90 > - ;; but we don't need to see them.
\r
92 > - (setq name (replace-regexp-in-string "\"" "" name)))
\r
93 > + (let (p-name p-address)
\r
94 > + ;; It would be convenient to use `mail-header-parse-address',
\r
95 > + ;; but that expects un-decoded mailbox parts, whereas our
\r
96 > + ;; mailbox parts are already decoded (and hence may contain
\r
97 > + ;; UTF-8). Given that notmuch should handle most of the awkward
\r
98 > + ;; cases, some simple string deconstruction should be sufficient
\r
101 > + ;; "User <user@dom.ain>" style.
\r
102 > + ((string-match "\\(.*\\) <\\(.*\\)>" address)
\r
103 > + (setq p-name (match-string 1 address)
\r
104 > + p-address (match-string 2 address)))
\r
106 > + ;; "<user@dom.ain>" style.
\r
107 > + ((string-match "<\\(.*\\)>" address)
\r
108 > + (setq p-address (match-string 1 address)))
\r
110 > + ;; Everything else.
\r
112 > + (setq p-address address)))
\r
114 > + ;; Remove outer double quotes. They might be required during
\r
115 > + ;; transport, but we don't need to see them.
\r
116 > + (when (and p-name
\r
117 > + (string-match "^\"\\(.*\\)\"$" p-name))
\r
118 > + (setq p-name (match-string 1 p-name)))
\r
120 > ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
\r
121 > ;; 'foo@bar.com'.
\r
122 > - (when (string=3D name address)
\r
123 > - (setq name nil))
\r
127 > - (concat name " <" address ">")))
\r
128 > + (when (string=3D p-name p-address)
\r
129 > + (setq p-name nil))
\r
131 > + ;; If no name results, return just the address.
\r
132 > + (if (not p-name)
\r
134 > + ;; Otherwise format the name and address together.
\r
135 > + (concat p-name " <" p-address ">")))
\r
136 > (error address)))
\r
138 > (defun notmuch-show-insert-headerline (headers date tags depth)
\r
139 > @@ -1417,7 +1439,7 @@ than only the current message."
\r
140 > (interactive "P\nsPipe message to command: ")
\r
141 > (let (shell-command)
\r
142 > (if entire-thread
\r
143 > - (setq shell-command=20
\r
144 > + (setq shell-command
\r
145 > (concat notmuch-command " show --format=3Dmbox "
\r
146 > (shell-quote-argument
\r
147 > (mapconcat 'identity (notmuch-show-get-message-ids-for-open-mes=
\r
149 > diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning=
\r
151 > index 0d85bdc..51018fe 100755
\r
152 > --- a/test/emacs-address-cleaning.sh
\r
153 > +++ b/test/emacs-address-cleaning.sh
\r
154 > @@ -12,7 +12,6 @@ test_emacs_expect_t \
\r
155 > '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-2=
\r
158 > test_begin_subtest "notmuch-test-address-clean part 3"
\r
159 > -test_subtest_known_broken
\r
160 > test_emacs_expect_t \
\r
161 > '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-3=
\r
169 Works fine for me, but this also breaks en Emacs test:
\r
171 FAIL notmuch-show for message with invalid From
\r
172 --- emacs.10.expected 2012-01-25 12:50:00.310786410 +0000
\r
173 +++ emacs.10.output 2012-01-25 12:50:00.310786410 +0000
\r
175 -"Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
\r
176 +Invalid " From <test_suite@notmuchmail.org> (2001-01-05) (inbox)
\r
177 Subject: message-with-invalid-from
\r
178 To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
179 Date: Fri, 05 Jan 2001 15:43:57 +0000
\r
182 Thanks for this patch anyway :)
\r
190 Content-Type: application/pgp-signature
\r
192 -----BEGIN PGP SIGNATURE-----
\r
193 Version: GnuPG v1.4.11 (GNU/Linux)
\r
195 iQEcBAEBAgAGBQJPH/riAAoJEMPdciX+bh5IyWQH/iablZAbREuMGWochZi5wUqp
\r
196 QqvODN5n9ejDHtYYKI3y3YjbrOTJu2MVU1pPlYrvnL3tQWHfu0lsDrhMnrqOn5NV
\r
197 B3sx/VLj6BJiC1Pvh9oDtDk6zy5rgc5H2iugCucu9083SL/eC1HMfbyEEpEQHBtq
\r
198 6JZG8fOqxqFxIddqSca+QPEQKHS2+zz+HQhO+IMGQWAQVhcD3aNV59EVVxlb7YKt
\r
199 CeLG3H+oNTGGum3CqLXu1WHmkgcfGGRziMeMFmen1QXjHTuSUFIr2SkTDbJ0FmMP
\r
200 79cQsUqaO1R7lYtghnOa9Fg8bbL3/P81IGfhAO/Qr0NqYcTqeohCm+lfm0dz+Fg=
\r
202 -----END PGP SIGNATURE-----
\r