[PATCH 10/25] Sanitize "Subject:" and "Author:" fields to not contain control charact...
authorJameson Graef Rollins <jrollins@finestructure.net>
Sat, 28 May 2011 21:51:45 +0000 (14:51 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:26 +0000 (09:38 -0800)
61/3aff1d2e72a3b877516bfb93b026b94f476c8b [new file with mode: 0644]

diff --git a/61/3aff1d2e72a3b877516bfb93b026b94f476c8b b/61/3aff1d2e72a3b877516bfb93b026b94f476c8b
new file mode 100644 (file)
index 0000000..3e1d63c
--- /dev/null
@@ -0,0 +1,125 @@
+Return-Path: <jrollins@servo.finestructure.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 02DE2429E30\r
+       for <notmuch@notmuchmail.org>; Sat, 28 May 2011 14:52:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.921\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5\r
+       tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id DfMa8mC1tdMt for <notmuch@notmuchmail.org>;\r
+       Sat, 28 May 2011 14:52:24 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+       [131.215.239.19])\r
+       by olra.theworths.org (Postfix) with ESMTP id AB802429E39\r
+       for <notmuch@notmuchmail.org>; Sat, 28 May 2011 14:52:15 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by fire-doxen-postvirus (Postfix) with ESMTP id 26A04328121;\r
+       Sat, 28 May 2011 14:45:48 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com\r
+       [98.149.172.122]) (Authenticated sender: jrollins)\r
+       by fire-doxen-submit (Postfix) with ESMTP id 895AE2E50EB3;\r
+       Sat, 28 May 2011 14:45:43 -0700 (PDT)\r
+Received: by servo.finestructure.net (Postfix, from userid 1000)\r
+       id 320DB7AC; Sat, 28 May 2011 14:52:05 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 10/25] Sanitize "Subject:" and "Author:" fields to not contain\r
+       control characters in notmuch-search\r
+Date: Sat, 28 May 2011 14:51:45 -0700\r
+Message-Id: <1306619520-25730-11-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.4.4\r
+In-Reply-To: <1306619520-25730-10-git-send-email-jrollins@finestructure.net>\r
+References: <1306619520-25730-1-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-2-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-3-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-4-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-5-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-6-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-7-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-8-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-9-git-send-email-jrollins@finestructure.net>\r
+       <1306619520-25730-10-git-send-email-jrollins@finestructure.net>\r
+Cc: Andreas Amann <a.amann@ucc.ie>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 28 May 2011 21:52:26 -0000\r
+\r
+From: Andreas Amann <a.amann@ucc.ie>\r
+\r
+When a Subject field contained encoded CRLF sequences, these sequences\r
+would appear unfiltered in the output of notmuch search. This confused\r
+the notmuch emacs interface leading to "Unexpected Output"\r
+messages. This is now fixed by replacing all characters with ASCII\r
+code less than 32 with a question mark.\r
+\r
+Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>\r
+---\r
+ notmuch-search.c |   22 ++++++++++++++++++++--\r
+ 1 files changed, 20 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 69af617..530cecc 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -111,6 +111,20 @@ format_item_id_text (unused (const void *ctx),\r
+     printf ("%s%s", item_type, item_id);\r
+ }\r
\r
++static char *\r
++sanitize_string (const void *ctx, const char *str)\r
++{\r
++    char *out, *loop;\r
++\r
++    loop = out = talloc_strdup (ctx, str);\r
++\r
++    for (; *loop; loop++) {\r
++      if ((unsigned char)(*loop) < 32)\r
++          *loop = '?';\r
++    }\r
++    return out;\r
++}\r
++\r
+ static void\r
+ format_thread_text (const void *ctx,\r
+                   const char *thread_id,\r
+@@ -120,13 +134,17 @@ format_thread_text (const void *ctx,\r
+                   const char *authors,\r
+                   const char *subject)\r
+ {\r
++    void *ctx_quote = talloc_new (ctx);\r
++\r
+     printf ("thread:%s %12s [%d/%d] %s; %s",\r
+           thread_id,\r
+           notmuch_time_relative_date (ctx, date),\r
+           matched,\r
+           total,\r
+-          authors,\r
+-          subject);\r
++          sanitize_string (ctx_quote, authors),\r
++          sanitize_string (ctx_quote, subject));\r
++\r
++    talloc_free (ctx_quote);\r
+ }\r
\r
+ static void\r
+-- \r
+1.7.4.4\r
+\r