Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 61 / 3aff1d2e72a3b877516bfb93b026b94f476c8b
1 Return-Path: <jrollins@servo.finestructure.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 02DE2429E30\r
6         for <notmuch@notmuchmail.org>; Sat, 28 May 2011 14:52:26 -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: -1.921\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5\r
12         tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3]\r
13         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 DfMa8mC1tdMt for <notmuch@notmuchmail.org>;\r
17         Sat, 28 May 2011 14:52:24 -0700 (PDT)\r
18 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
19         [131.215.239.19])\r
20         by olra.theworths.org (Postfix) with ESMTP id AB802429E39\r
21         for <notmuch@notmuchmail.org>; Sat, 28 May 2011 14:52:15 -0700 (PDT)\r
22 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
23         by fire-doxen-postvirus (Postfix) with ESMTP id 26A04328121;\r
24         Sat, 28 May 2011 14:45:48 -0700 (PDT)\r
25 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
26 Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com\r
27         [98.149.172.122]) (Authenticated sender: jrollins)\r
28         by fire-doxen-submit (Postfix) with ESMTP id 895AE2E50EB3;\r
29         Sat, 28 May 2011 14:45:43 -0700 (PDT)\r
30 Received: by servo.finestructure.net (Postfix, from userid 1000)\r
31         id 320DB7AC; Sat, 28 May 2011 14:52:05 -0700 (PDT)\r
32 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
33 To: Notmuch Mail <notmuch@notmuchmail.org>\r
34 Subject: [PATCH 10/25] Sanitize "Subject:" and "Author:" fields to not contain\r
35         control characters in notmuch-search\r
36 Date: Sat, 28 May 2011 14:51:45 -0700\r
37 Message-Id: <1306619520-25730-11-git-send-email-jrollins@finestructure.net>\r
38 X-Mailer: git-send-email 1.7.4.4\r
39 In-Reply-To: <1306619520-25730-10-git-send-email-jrollins@finestructure.net>\r
40 References: <1306619520-25730-1-git-send-email-jrollins@finestructure.net>\r
41         <1306619520-25730-2-git-send-email-jrollins@finestructure.net>\r
42         <1306619520-25730-3-git-send-email-jrollins@finestructure.net>\r
43         <1306619520-25730-4-git-send-email-jrollins@finestructure.net>\r
44         <1306619520-25730-5-git-send-email-jrollins@finestructure.net>\r
45         <1306619520-25730-6-git-send-email-jrollins@finestructure.net>\r
46         <1306619520-25730-7-git-send-email-jrollins@finestructure.net>\r
47         <1306619520-25730-8-git-send-email-jrollins@finestructure.net>\r
48         <1306619520-25730-9-git-send-email-jrollins@finestructure.net>\r
49         <1306619520-25730-10-git-send-email-jrollins@finestructure.net>\r
50 Cc: Andreas Amann <a.amann@ucc.ie>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sat, 28 May 2011 21:52:26 -0000\r
64 \r
65 From: Andreas Amann <a.amann@ucc.ie>\r
66 \r
67 When a Subject field contained encoded CRLF sequences, these sequences\r
68 would appear unfiltered in the output of notmuch search. This confused\r
69 the notmuch emacs interface leading to "Unexpected Output"\r
70 messages. This is now fixed by replacing all characters with ASCII\r
71 code less than 32 with a question mark.\r
72 \r
73 Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>\r
74 ---\r
75  notmuch-search.c |   22 ++++++++++++++++++++--\r
76  1 files changed, 20 insertions(+), 2 deletions(-)\r
77 \r
78 diff --git a/notmuch-search.c b/notmuch-search.c\r
79 index 69af617..530cecc 100644\r
80 --- a/notmuch-search.c\r
81 +++ b/notmuch-search.c\r
82 @@ -111,6 +111,20 @@ format_item_id_text (unused (const void *ctx),\r
83      printf ("%s%s", item_type, item_id);\r
84  }\r
85  \r
86 +static char *\r
87 +sanitize_string (const void *ctx, const char *str)\r
88 +{\r
89 +    char *out, *loop;\r
90 +\r
91 +    loop = out = talloc_strdup (ctx, str);\r
92 +\r
93 +    for (; *loop; loop++) {\r
94 +       if ((unsigned char)(*loop) < 32)\r
95 +           *loop = '?';\r
96 +    }\r
97 +    return out;\r
98 +}\r
99 +\r
100  static void\r
101  format_thread_text (const void *ctx,\r
102                     const char *thread_id,\r
103 @@ -120,13 +134,17 @@ format_thread_text (const void *ctx,\r
104                     const char *authors,\r
105                     const char *subject)\r
106  {\r
107 +    void *ctx_quote = talloc_new (ctx);\r
108 +\r
109      printf ("thread:%s %12s [%d/%d] %s; %s",\r
110             thread_id,\r
111             notmuch_time_relative_date (ctx, date),\r
112             matched,\r
113             total,\r
114 -           authors,\r
115 -           subject);\r
116 +           sanitize_string (ctx_quote, authors),\r
117 +           sanitize_string (ctx_quote, subject));\r
118 +\r
119 +    talloc_free (ctx_quote);\r
120  }\r
121  \r
122  static void\r
123 -- \r
124 1.7.4.4\r
125 \r