Re: Problem with "Unexpected output" messages
authorAndreas Amann <a.amann@ucc.ie>
Fri, 15 Apr 2011 11:28:00 +0000 (12:28 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:04 +0000 (09:38 -0800)
62/7b8e6495c4eea7f8f544939d9bae836c418d8c [new file with mode: 0644]

diff --git a/62/7b8e6495c4eea7f8f544939d9bae836c418d8c b/62/7b8e6495c4eea7f8f544939d9bae836c418d8c
new file mode 100644 (file)
index 0000000..299aabb
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <a.amann@ucc.ie>\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 7C780431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 04:28:09 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 2kofIuPdfss6 for <notmuch@notmuchmail.org>;\r
+       Fri, 15 Apr 2011 04:28:09 -0700 (PDT)\r
+Received: from mail4.ucc.ie (mail4.ucc.ie [143.239.1.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id B54FA431FB5\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 04:28:08 -0700 (PDT)\r
+Received: from msstf091.ucc.ie (msstf091.ucc.ie [143.239.76.91])\r
+       by mail4.ucc.ie (8.14.4/8.14.4) with ESMTP id p3FBS0Qv014913\r
+       for <notmuch@notmuchmail.org>; Fri, 15 Apr 2011 12:28:05 +0100\r
+Received: by msstf091.ucc.ie (Postfix, from userid 1000)\r
+       id 7182A62B3C; Fri, 15 Apr 2011 12:28:00 +0100 (IST)\r
+From: Andreas Amann <a.amann@ucc.ie>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: Problem with "Unexpected output" messages\r
+In-Reply-To: <87pqozi3q2.fsf@msstf091.ucc.ie>\r
+References: <87pqozi3q2.fsf@msstf091.ucc.ie>\r
+User-Agent: Notmuch/0.5-138-g91d61c7 (http://notmuchmail.org) Emacs/24.0.50.1\r
+       (x86_64-unknown-linux-gnu)\r
+Date: Fri, 15 Apr 2011 12:28:00 +0100\r
+Message-ID: <8739ljwy7z.fsf@msstf091.ucc.ie>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-MD-NoSA: yes\r
+X-Scanned-By: MIMEDefang 2.68 on 143.239.1.34\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: Fri, 15 Apr 2011 11:28:09 -0000\r
+\r
+On Wed, 06 Apr 2011 20:23:17 +0100, Andreas Amann <a.amann@ucc.ie> wrote:\r
+> \r
+> since commit 44d3c57e (emacs: Display any unexpected output from notmuch\r
+> search) I see a number of messages of the form\r
+> \r
+> Error: Unexpected output from notmuch search:\r
+> thread:000000000000XXXX \r
+> \r
+> after notmuch-search in emacs. \r
+\r
+\r
+FWIW, the patch below solves the problem for me.\r
+\r
+Andreas\r
+\r
+---------------------\r
+[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search\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
+ 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 8b90121..fc13e60 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -108,6 +108,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
+@@ -117,13 +131,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.1\r
+\r