Re: [PATCH v6 4/6] emacs/mua: Generate improved cited text for replies
[notmuch-archives.git] / 23 / 29ae166db1c05071eb4be731a309366f4f2da3
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 65912429E20\r
6         for <notmuch@notmuchmail.org>; Sun,  8 May 2011 14:40:56 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \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 zHw+IKJdQqSS for <notmuch@notmuchmail.org>;\r
17         Sun,  8 May 2011 14:40:55 -0700 (PDT)\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
19         [209.85.216.181]) (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 4AE71431FB5\r
22         for <notmuch@notmuchmail.org>; Sun,  8 May 2011 14:40:55 -0700 (PDT)\r
23 Received: by qyg14 with SMTP id 14so3973688qyg.5\r
24         for <notmuch@notmuchmail.org>; Sun, 08 May 2011 14:40:54 -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=S8gzT71XuMiOkXHyWTYqhb3Y/6Zzo4sfdXx+BmPBdqA=;\r
30         b=LBaXcMwaaO2Iah8qfN6dJgLoNbhXGspHCwF9JWBi2dTE0E/itqaB4iLV0xf/cjOf4Y\r
31         p215+QWIP395hZ/VsY0xgEY+zTK7jOIjDetuGseaUxel17c6XgodayJdBn1UTmLdEtin\r
32         o8iZI15SJsacofYmM8u8aD8JFpYDPERdUa7Ok=\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=VLfQ05ZFhkyK9qOYBdSfqyhccCX/R7bMWNOrkcY7slnjCJfC6JVsiOT+P6uA90WXV3\r
38         llWagUSHPN3JDRqO+esEQ1T6LmgcX/3oiNeJ5q7edd91xKXXhqIuUdKcN2jdrQcnqlFC\r
39         eMiGYL0sUMDmsY1jbj5MW4exgYaF7q1Ta+XEI=\r
40 MIME-Version: 1.0\r
41 Received: by 10.229.128.158 with SMTP id k30mr4525322qcs.188.1304890854510;\r
42         Sun, 08 May 2011 14:40:54 -0700 (PDT)\r
43 Sender: amdragon@gmail.com\r
44 Received: by 10.229.233.17 with HTTP; Sun, 8 May 2011 14:40:54 -0700 (PDT)\r
45 In-Reply-To: <1304889273-24560-2-git-send-email-flo@chaoflow.net>\r
46 References: <87liyjgvyw.fsf@servo.factory.finestructure.net>\r
47         <1304889273-24560-1-git-send-email-flo@chaoflow.net>\r
48         <1304889273-24560-2-git-send-email-flo@chaoflow.net>\r
49 Date: Sun, 8 May 2011 17:40:54 -0400\r
50 X-Google-Sender-Auth: DPj0sST1ZtUPKyRBYQo_9t4TcNo\r
51 Message-ID: <BANLkTi=ta-abS09Wa7=2_k7Q307u_Y4A0Q@mail.gmail.com>\r
52 Subject: Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain\r
53         control characters in notmuch-search\r
54 From: Austin Clements <amdragon@mit.edu>\r
55 To: Florian Friesdorf <flo@chaoflow.net>\r
56 Content-Type: text/plain; charset=ISO-8859-1\r
57 Content-Transfer-Encoding: quoted-printable\r
58 Cc: notmuch@notmuchmail.org, Andreas Amann <a.amann@ucc.ie>\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Sun, 08 May 2011 21:40:56 -0000\r
72 \r
73 Cool.  This seems very reasonable.\r
74 \r
75 Just some style nits: The three places where you have\r
76 "sanitize_string(", there should be a space between the function name\r
77 and the paren.  Relatedly, "for(;*loop;loop++){" should be spaced out\r
78 like "for (; *loop; loop++) {".  (Curiously, there seems to be\r
79 anti-consensus on whether the brace should be on the same line or the\r
80 next, but otherwise the notmuch code is quite consistent about\r
81 spacing.)  Also, existing code conventionally uses a variable named\r
82 "local" for function-level talloc contexts such as your ctx_quote.\r
83 \r
84 On Sun, May 8, 2011 at 5:14 PM, Florian Friesdorf <flo@chaoflow.net> wrote:\r
85 > From: Andreas Amann <a.amann@ucc.ie>\r
86 >\r
87 > When a Subject field contained encoded CRLF sequences, these sequences\r
88 > would appear unfiltered in the output of notmuch search. This confused\r
89 > the notmuch emacs interface leading to "Unexpected Output"\r
90 > messages. This is now fixed by replacing all characters with ASCII\r
91 > code less than 32 with a question mark.\r
92 > ---\r
93 > =A0notmuch-search.c | =A0 22 ++++++++++++++++++++--\r
94 > =A01 files changed, 20 insertions(+), 2 deletions(-)\r
95 >\r
96 > diff --git a/notmuch-search.c b/notmuch-search.c\r
97 > index 5e39511..e7fc41a 100644\r
98 > --- a/notmuch-search.c\r
99 > +++ b/notmuch-search.c\r
100 > @@ -111,6 +111,20 @@ format_item_id_text (unused (const void *ctx),\r
101 > =A0 =A0 printf ("%s%s", item_type, item_id);\r
102 > =A0}\r
103 >\r
104 > +static char *\r
105 > +sanitize_string(const void *ctx, const char *str)\r
106 > +{\r
107 > + =A0 =A0char *out, *loop;\r
108 > +\r
109 > + =A0 =A0loop =3D out =3D talloc_strdup (ctx, str);\r
110 > +\r
111 > + =A0 =A0for(;*loop;loop++){\r
112 > + =A0 =A0 =A0 if ((unsigned char)(*loop) < 32)\r
113 > + =A0 =A0 =A0 =A0 =A0 *loop =3D '?';\r
114 > + =A0 =A0}\r
115 > + =A0 =A0return out;\r
116 > +}\r
117 > +\r
118 > =A0static void\r
119 > =A0format_thread_text (const void *ctx,\r
120 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *thread_id,\r
121 > @@ -120,13 +134,17 @@ format_thread_text (const void *ctx,\r
122 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *authors,\r
123 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *subject)\r
124 > =A0{\r
125 > + =A0 =A0void *ctx_quote =3D talloc_new (ctx);\r
126 > +\r
127 > =A0 =A0 printf ("thread:%s %12s [%d/%d] %s; %s",\r
128 > =A0 =A0 =A0 =A0 =A0 =A0thread_id,\r
129 > =A0 =A0 =A0 =A0 =A0 =A0notmuch_time_relative_date (ctx, date),\r
130 > =A0 =A0 =A0 =A0 =A0 =A0matched,\r
131 > =A0 =A0 =A0 =A0 =A0 =A0total,\r
132 > - =A0 =A0 =A0 =A0 =A0 authors,\r
133 > - =A0 =A0 =A0 =A0 =A0 subject);\r
134 > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, authors),\r
135 > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, subject));\r
136 > +\r
137 > + =A0 =A0talloc_free (ctx_quote);\r
138 > =A0}\r
139 >\r
140 > =A0static void\r
141 > --\r
142 > 1.7.5.1\r
143 >\r
144 > _______________________________________________\r
145 > notmuch mailing list\r
146 > notmuch@notmuchmail.org\r
147 > http://notmuchmail.org/mailman/listinfo/notmuch\r
148 >\r