1 Return-Path: <amdragon@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 84435429E21
\r
6 for <notmuch@notmuchmail.org>; Fri, 6 May 2011 16:55:28 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,
\r
13 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 sSKkeQYq+PfT for <notmuch@notmuchmail.org>;
\r
17 Fri, 6 May 2011 16:55:27 -0700 (PDT)
\r
18 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com
\r
19 [209.85.216.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 6F515431FB5
\r
22 for <notmuch@notmuchmail.org>; Fri, 6 May 2011 16:55:27 -0700 (PDT)
\r
23 Received: by qyk7 with SMTP id 7so23655qyk.5
\r
24 for <notmuch@notmuchmail.org>; Fri, 06 May 2011 16:55:26 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=domainkey-signature:mime-version:sender:in-reply-to:references:date
\r
27 :x-google-sender-auth:message-id:subject:from:to:cc:content-type
\r
28 :content-transfer-encoding;
\r
29 bh=2je4+iH5PdpwKGYxTZeQ+1y5fHqfavG7+7g9XegRa2M=;
\r
30 b=sYQM4vj76VaTTShyLOKW1EDWWADQglzplxRppKBDdfOSA9ZqDPeiuWs17fJoITheOA
\r
31 BQrp8aDOEqCIsVyE335Z5ItkGihWgj0jFidS/hufDG9V8dIBH+WyQwYJLZR2z6gOl3nk
\r
32 ePy5HoijvxdpkLIFrR9CFKuQ6nKL5wE8srfFc=
\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
34 h=mime-version:sender:in-reply-to:references:date
\r
35 :x-google-sender-auth:message-id:subject:from:to:cc:content-type
\r
36 :content-transfer-encoding;
\r
37 b=LusDxLebVib1+/MngA517OY44ByfTmFycuT5olTnIsu7p7+wR7wrLiEkoEj7Dx8ErY
\r
38 OI20VUJYQ0lpzJHPExs+8LC/oMW3zQl8oJsaQzPBwHHUGkTQiR082xfyEoYqeaODfTQv
\r
39 AJQV8qns1OWk81JHLIoMVHKur8GW9omVOV5bw=
\r
41 Received: by 10.229.101.36 with SMTP id a36mr3014761qco.74.1304726126591; Fri,
\r
42 06 May 2011 16:55:26 -0700 (PDT)
\r
43 Sender: amdragon@gmail.com
\r
44 Received: by 10.229.233.17 with HTTP; Fri, 6 May 2011 16:55:26 -0700 (PDT)
\r
45 In-Reply-To: <1304723846-29134-2-git-send-email-flo@chaoflow.net>
\r
46 References: <1304723846-29134-1-git-send-email-flo@chaoflow.net>
\r
47 <1304723846-29134-2-git-send-email-flo@chaoflow.net>
\r
48 Date: Fri, 6 May 2011 19:55:26 -0400
\r
49 X-Google-Sender-Auth: yVZg5jVvvyZshUIe7a8_vyhw3Ps
\r
50 Message-ID: <BANLkTime86NE4W5j+p0uJiR5_cF3gZVd8Q@mail.gmail.com>
\r
51 Subject: Re: [PATCH] implement search --format=sanitized_text + emacs UI to
\r
53 From: Austin Clements <amdragon@mit.edu>
\r
54 To: Florian Friesdorf <flo@chaoflow.net>
\r
55 Content-Type: text/plain; charset=ISO-8859-1
\r
56 Content-Transfer-Encoding: quoted-printable
\r
57 Cc: notmuch@notmuchmail.org, a.amann@ucc.ie
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Fri, 06 May 2011 23:55:28 -0000
\r
72 Perhaps text summary output should *always* do this. The text summary
\r
73 format is meant half for user consumption and half for emacs
\r
74 consumption and allowing newlines that don't indicate the end of a
\r
75 summary line seems bad for *both* use cases.
\r
77 On Fri, May 6, 2011 at 7:17 PM, Florian Friesdorf <flo@chaoflow.net> wrote:
\r
78 > Sanitize "Subject:" and "Author:" fields to not contain control
\r
79 > characters for sanitized_text format.
\r
81 > When a Subject field contains encoded CRLF sequences, these sequences
\r
82 > would appear unfiltered in the output of notmuch search. This confused
\r
83 > the notmuch emacs interface leading to "Unexpected Output"
\r
84 > messages. This is now fixed by replacing all characters with ASCII
\r
85 > code less than 32 with a question mark for the sanitized_text
\r
86 > format. The emacs UI uses this format.
\r
88 > Thank you to Andreas Amann <a.amann@ucc.ie>, who wrote the initial
\r
89 > patch, I just turned it into a new format.
\r
93 > - test, (works for me)
\r
94 > - investigate initialization warning:
\r
95 > CC -O2 notmuch-search.o
\r
96 > notmuch-search.c:98:1: warning: missing initializer
\r
97 > notmuch-search.c:98:1: warning: (near initialization for
\r
98 > 'format_sanitized_text.results_null')
\r
100 > =A0emacs/notmuch.el | =A0 =A03 +-
\r
101 > =A0notmuch-search.c | =A0 58 ++++++++++++++++++++++++++++++++++++++++++++=
\r
103 > =A02 files changed, 60 insertions(+), 1 deletions(-)
\r
105 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
106 > index 1d683f8..9d7c212 100644
\r
107 > --- a/emacs/notmuch.el
\r
108 > +++ b/emacs/notmuch.el
\r
109 > @@ -879,7 +879,8 @@ The optional parameters are used as follows:
\r
110 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if oldest-first
\r
111 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "--sort=3Doldest-first"
\r
112 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "--sort=3Dnewest-first")
\r
113 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0query)))
\r
114 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "--format=3Dsanitized_text"
\r
115 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 query)))
\r
116 > =A0 =A0 =A0 =A0 =A0(set-process-sentinel proc 'notmuch-search-process-sen=
\r
118 > =A0 =A0 =A0 =A0 =A0(set-process-filter proc 'notmuch-search-process-filte=
\r
120 > =A0 =A0 (run-hooks 'notmuch-search-hook)))
\r
121 > diff --git a/notmuch-search.c b/notmuch-search.c
\r
122 > index 5e39511..d59dc44 100644
\r
123 > --- a/notmuch-search.c
\r
124 > +++ b/notmuch-search.c
\r
125 > @@ -78,6 +78,26 @@ static const search_format_t format_text =3D {
\r
129 > +format_thread_sanitized_text (const void *ctx,
\r
130 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *thr=
\r
132 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const time_t da=
\r
134 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const int match=
\r
136 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const int total=
\r
138 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *aut=
\r
140 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *sub=
\r
142 > +static const search_format_t format_sanitized_text =3D {
\r
144 > + =A0 =A0 =A0 "",
\r
145 > + =A0 =A0 =A0 =A0 =A0 format_item_id_text,
\r
146 > + =A0 =A0 =A0 =A0 =A0 format_thread_sanitized_text,
\r
147 > + =A0 =A0 =A0 =A0 =A0 " (",
\r
148 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "%s", " ",
\r
149 > + =A0 =A0 =A0 =A0 =A0 ")", "\n",
\r
150 > + =A0 =A0 =A0 "",
\r
155 > =A0format_item_id_json (const void *ctx,
\r
156 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *item_type,
\r
157 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *item_id);
\r
158 > @@ -129,6 +149,42 @@ format_thread_text (const void *ctx,
\r
159 > =A0 =A0 =A0 =A0 =A0 =A0subject);
\r
163 > +sanitize_string(const void *ctx, const char *str)
\r
165 > + =A0 =A0char *out, *loop;
\r
167 > + =A0 =A0loop =3D out =3D talloc_strdup (ctx, str);
\r
169 > + =A0 =A0for(;*loop;loop++){
\r
170 > + =A0 =A0 =A0 if ((unsigned char)(*loop) < 32)
\r
171 > + =A0 =A0 =A0 =A0 =A0 *loop =3D '?';
\r
173 > + =A0 =A0return out;
\r
177 > +format_thread_sanitized_text (const void *ctx,
\r
178 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *thr=
\r
180 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const time_t da=
\r
182 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const int match=
\r
184 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const int total=
\r
186 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *aut=
\r
188 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *sub=
\r
191 > + =A0 =A0void *ctx_quote =3D talloc_new (ctx);
\r
193 > + =A0 =A0printf ("thread:%s %12s [%d/%d] %s; %s",
\r
194 > + =A0 =A0 =A0 =A0 =A0 thread_id,
\r
195 > + =A0 =A0 =A0 =A0 =A0 notmuch_time_relative_date (ctx, date),
\r
196 > + =A0 =A0 =A0 =A0 =A0 matched,
\r
197 > + =A0 =A0 =A0 =A0 =A0 total,
\r
198 > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, authors),
\r
199 > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, subject));
\r
201 > + =A0 =A0talloc_free (ctx_quote);
\r
205 > =A0format_item_id_json (const void *ctx,
\r
206 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unused (const char *item_type),
\r
207 > @@ -378,6 +434,8 @@ notmuch_search_command (void *ctx, int argc, char *ar=
\r
209 > =A0 =A0 =A0 =A0 =A0 =A0opt =3D argv[i] + sizeof ("--format=3D") - 1;
\r
210 > =A0 =A0 =A0 =A0 =A0 =A0if (strcmp (opt, "text") =3D=3D 0) {
\r
211 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0format =3D &format_text;
\r
212 > + =A0 =A0 =A0 =A0 =A0 } else if (strcmp (opt, "sanitized_text") =3D=3D 0)=
\r
214 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 format =3D &format_sanitized_text;
\r
215 > =A0 =A0 =A0 =A0 =A0 =A0} else if (strcmp (opt, "json") =3D=3D 0) {
\r
216 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0format =3D &format_json;
\r
217 > =A0 =A0 =A0 =A0 =A0 =A0} else {
\r
221 > _______________________________________________
\r
222 > notmuch mailing list
\r
223 > notmuch@notmuchmail.org
\r
224 > http://notmuchmail.org/mailman/listinfo/notmuch
\r