Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 4f / 432e6e153944b3b175f690937f1f40c56fdb77
1 Return-Path: <flo@chaoflow.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 28FEC429E23\r
6         for <notmuch@notmuchmail.org>; Sun,  8 May 2011 14:15:06 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 zSBt7oq5+r1O for <notmuch@notmuchmail.org>;\r
16         Sun,  8 May 2011 14:15:04 -0700 (PDT)\r
17 Received: from tesla.chaoflow.net (tesla.chaoflow.net [188.40.54.22])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B5499429E22\r
21         for <notmuch@notmuchmail.org>; Sun,  8 May 2011 14:15:03 -0700 (PDT)\r
22 Received: from eve.chaoflow.net (host-188-174-146-106.customer.m-online.net\r
23         [188.174.146.106])\r
24         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
25         (No client certificate requested)\r
26         (Authenticated sender: flo@chaoflow.net)\r
27         by tesla.chaoflow.net (Postfix) with ESMTPSA id 409A3C7A2;\r
28         Sun,  8 May 2011 23:15:02 +0200 (CEST)\r
29 Received: from eve.fritz.box (eve.chaoflow.net [127.0.0.1])\r
30         by eve.chaoflow.net (Postfix) with ESMTP id 082212AC; Sun,\r
31         8 May 2011 21:15:02 +0000 (Local time zone must be set--see zic manual\r
32         page)\r
33 From: Florian Friesdorf <flo@chaoflow.net>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain\r
36         control characters in notmuch-search\r
37 Date: Sun,  8 May 2011 23:14:33 +0200\r
38 Message-Id: <1304889273-24560-2-git-send-email-flo@chaoflow.net>\r
39 X-Mailer: git-send-email 1.7.5.1\r
40 In-Reply-To: <1304889273-24560-1-git-send-email-flo@chaoflow.net>\r
41 References: <87liyjgvyw.fsf@servo.factory.finestructure.net>\r
42         <1304889273-24560-1-git-send-email-flo@chaoflow.net>\r
43 X-Virus-Scanned: clamav-milter 0.96.5 at tesla\r
44 X-Virus-Status: Clean\r
45 Cc: Andreas Amann <a.amann@ucc.ie>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\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: Sun, 08 May 2011 21:15:06 -0000\r
59 \r
60 From: Andreas Amann <a.amann@ucc.ie>\r
61 \r
62 When a Subject field contained encoded CRLF sequences, these sequences\r
63 would appear unfiltered in the output of notmuch search. This confused\r
64 the notmuch emacs interface leading to "Unexpected Output"\r
65 messages. This is now fixed by replacing all characters with ASCII\r
66 code less than 32 with a question mark.\r
67 ---\r
68  notmuch-search.c |   22 ++++++++++++++++++++--\r
69  1 files changed, 20 insertions(+), 2 deletions(-)\r
70 \r
71 diff --git a/notmuch-search.c b/notmuch-search.c\r
72 index 5e39511..e7fc41a 100644\r
73 --- a/notmuch-search.c\r
74 +++ b/notmuch-search.c\r
75 @@ -111,6 +111,20 @@ format_item_id_text (unused (const void *ctx),\r
76      printf ("%s%s", item_type, item_id);\r
77  }\r
78  \r
79 +static char *\r
80 +sanitize_string(const void *ctx, const char *str)\r
81 +{\r
82 +    char *out, *loop;\r
83 +\r
84 +    loop = out = talloc_strdup (ctx, str);\r
85 +\r
86 +    for(;*loop;loop++){\r
87 +       if ((unsigned char)(*loop) < 32)\r
88 +           *loop = '?';\r
89 +    }\r
90 +    return out;\r
91 +}\r
92 +\r
93  static void\r
94  format_thread_text (const void *ctx,\r
95                     const char *thread_id,\r
96 @@ -120,13 +134,17 @@ format_thread_text (const void *ctx,\r
97                     const char *authors,\r
98                     const char *subject)\r
99  {\r
100 +    void *ctx_quote = talloc_new (ctx);\r
101 +\r
102      printf ("thread:%s %12s [%d/%d] %s; %s",\r
103             thread_id,\r
104             notmuch_time_relative_date (ctx, date),\r
105             matched,\r
106             total,\r
107 -           authors,\r
108 -           subject);\r
109 +           sanitize_string(ctx_quote, authors),\r
110 +           sanitize_string(ctx_quote, subject));\r
111 +\r
112 +    talloc_free (ctx_quote);\r
113  }\r
114  \r
115  static void\r
116 -- \r
117 1.7.5.1\r
118 \r