unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pieter Praet <pieter@praet.org>
To: Andreas Amann <a.amann@ucc.ie>, Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: Problem with "Unexpected output" messages
Date: Sun, 17 Apr 2011 19:24:16 +0200	[thread overview]
Message-ID: <877haspz9b.fsf@A7GMS.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <8739ljwy7z.fsf@msstf091.ucc.ie>

On Fri, 15 Apr 2011 12:28:00 +0100, Andreas Amann <a.amann@ucc.ie> wrote:
> On Wed, 06 Apr 2011 20:23:17 +0100, Andreas Amann <a.amann@ucc.ie> wrote:
> > 
> > since commit 44d3c57e (emacs: Display any unexpected output from notmuch
> > search) I see a number of messages of the form
> > 
> > Error: Unexpected output from notmuch search:
> > thread:000000000000XXXX 
> > 
> > after notmuch-search in emacs. 
> 
> 
> FWIW, the patch below solves the problem for me.
> 
> Andreas
> 
> ---------------------
> [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
> 
> When a Subject field contained encoded CRLF sequences, these sequences
> would appear unfiltered in the output of notmuch search. This confused
> the notmuch emacs interface leading to "Unexpected Output"
> messages. This is now fixed by replacing all characters with ASCII
> code less than 32 with a question mark.
> ---
>  notmuch-search.c |   22 ++++++++++++++++++++--
>  1 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch-search.c b/notmuch-search.c
> index 8b90121..fc13e60 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -108,6 +108,20 @@ format_item_id_text (unused (const void *ctx),
>      printf ("%s%s", item_type, item_id);
>  }
>  
> +static char *
> +sanitize_string(const void *ctx, const char *str)
> +{
> +    char *out, *loop;
> +
> +    loop = out = talloc_strdup (ctx, str);
> +
> +    for(;*loop;loop++){
> +	if ((unsigned char)(*loop) < 32)
> +	    *loop = '?';
> +    }
> +    return out;
> +}
> +
>  static void
>  format_thread_text (const void *ctx,
>  		    const char *thread_id,
> @@ -117,13 +131,17 @@ format_thread_text (const void *ctx,
>  		    const char *authors,
>  		    const char *subject)
>  {
> +    void *ctx_quote = talloc_new (ctx);
> +
>      printf ("thread:%s %12s [%d/%d] %s; %s",
>  	    thread_id,
>  	    notmuch_time_relative_date (ctx, date),
>  	    matched,
>  	    total,
> -	    authors,
> -	    subject);
> +	    sanitize_string(ctx_quote, authors),
> +	    sanitize_string(ctx_quote, subject));
> +
> +    talloc_free (ctx_quote);
>  }
>  
>  static void
> -- 
> 1.7.4.1
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Works as advertised, but IMHO (since notmuch solely does indexing,
search and tagging) notmuch should return messages as truthful
(i.e. unaltered) as possible.

Any postprocessing should be the responsability of the MUA.

However, since notmuch already provides output formats, this could be
made part of those, eg. "--format=sanitized_text".


Peace

-Pieter

  parent reply	other threads:[~2011-04-17 17:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 19:23 Problem with "Unexpected output" messages Andreas Amann
2011-04-15 11:28 ` Andreas Amann
2011-04-17 15:56   ` Florian Friesdorf
2011-04-18  8:04     ` Andreas Amann
2011-04-17 17:24   ` Pieter Praet [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-05-07  9:20 Pieter Praet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877haspz9b.fsf@A7GMS.i-did-not-set--mail-host-address--so-tickle-me \
    --to=pieter@praet.org \
    --cc=a.amann@ucc.ie \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).