Re: Problem with "Unexpected output" messages
authorPieter Praet <pieter@praet.org>
Sun, 17 Apr 2011 17:24:16 +0000 (19:24 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:04 +0000 (09:38 -0800)
45/ba807862bc880c9ace7596fb4fcd8ab5b60b28 [new file with mode: 0644]

diff --git a/45/ba807862bc880c9ace7596fb4fcd8ab5b60b28 b/45/ba807862bc880c9ace7596fb4fcd8ab5b60b28
new file mode 100644 (file)
index 0000000..4e12190
--- /dev/null
@@ -0,0 +1,151 @@
+Return-Path: <pieter@praet.org>\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 2F202431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Apr 2011 10:24:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\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 vBZUpYnKxYnA for <notmuch@notmuchmail.org>;\r
+       Sun, 17 Apr 2011 10:24:24 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 43A1A431FB5\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Apr 2011 10:24:24 -0700 (PDT)\r
+Received: by wyi11 with SMTP id 11so4759431wyi.26\r
+       for <notmuch@notmuchmail.org>; Sun, 17 Apr 2011 10:24:22 -0700 (PDT)\r
+Received: by 10.227.149.73 with SMTP id s9mr4092852wbv.156.1303061060002;\r
+       Sun, 17 Apr 2011 10:24:20 -0700 (PDT)\r
+Received: from localhost (103.39-242-81.adsl-dyn.isp.belgacom.be\r
+       [81.242.39.103])\r
+       by mx.google.com with ESMTPS id bs4sm2783309wbb.1.2011.04.17.10.24.18\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 17 Apr 2011 10:24:19 -0700 (PDT)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Andreas Amann <a.amann@ucc.ie>, Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: Problem with "Unexpected output" messages\r
+In-Reply-To: <8739ljwy7z.fsf@msstf091.ucc.ie>\r
+References: <87pqozi3q2.fsf@msstf091.ucc.ie> <8739ljwy7z.fsf@msstf091.ucc.ie>\r
+User-Agent: Notmuch/0.5-86-g4875299 (http://notmuchmail.org) Emacs/23.1.50.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sun, 17 Apr 2011 19:24:16 +0200\r
+Message-ID:\r
+ <877haspz9b.fsf@A7GMS.i-did-not-set--mail-host-address--so-tickle-me>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Sun, 17 Apr 2011 17:24:26 -0000\r
+\r
+On Fri, 15 Apr 2011 12:28:00 +0100, Andreas Amann <a.amann@ucc.ie> wrote:\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+\r
+Works as advertised, but IMHO (since notmuch solely does indexing,\r
+search and tagging) notmuch should return messages as truthful\r
+(i.e. unaltered) as possible.\r
+\r
+Any postprocessing should be the responsability of the MUA.\r
+\r
+However, since notmuch already provides output formats, this could be\r
+made part of those, eg. "--format=sanitized_text".\r
+\r
+\r
+Peace\r
+\r
+-Pieter\r