unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@mit.edu>
To: Florian Friesdorf <flo@chaoflow.net>
Cc: notmuch@notmuchmail.org, Andreas Amann <a.amann@ucc.ie>
Subject: Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
Date: Sun, 8 May 2011 17:40:54 -0400	[thread overview]
Message-ID: <BANLkTi=ta-abS09Wa7=2_k7Q307u_Y4A0Q@mail.gmail.com> (raw)
In-Reply-To: <1304889273-24560-2-git-send-email-flo@chaoflow.net>

Cool.  This seems very reasonable.

Just some style nits: The three places where you have
"sanitize_string(", there should be a space between the function name
and the paren.  Relatedly, "for(;*loop;loop++){" should be spaced out
like "for (; *loop; loop++) {".  (Curiously, there seems to be
anti-consensus on whether the brace should be on the same line or the
next, but otherwise the notmuch code is quite consistent about
spacing.)  Also, existing code conventionally uses a variable named
"local" for function-level talloc contexts such as your ctx_quote.

On Sun, May 8, 2011 at 5:14 PM, Florian Friesdorf <flo@chaoflow.net> wrote:
> From: Andreas Amann <a.amann@ucc.ie>
>
> 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 5e39511..e7fc41a 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -111,6 +111,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,
> @@ -120,13 +134,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.5.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

  reply	other threads:[~2011-05-08 21:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06 23:17 [PATCH] search --format=sanitized_text Florian Friesdorf
2011-05-06 23:17 ` [PATCH] implement search --format=sanitized_text + emacs UI to use it Florian Friesdorf
2011-05-06 23:55   ` Austin Clements
2011-05-07  0:15     ` Florian Friesdorf
2011-05-07  1:06     ` Jameson Graef Rollins
2011-05-07  9:14       ` Pieter Praet
2011-05-07  9:25         ` Pieter Praet
2011-05-08 21:14       ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
2011-05-08 21:14         ` [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search Florian Friesdorf
2011-05-08 21:40           ` Austin Clements [this message]
2011-05-08 21:54             ` Florian Friesdorf
2011-05-08 22:02               ` Austin Clements
2011-05-08 23:12                 ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
2011-05-08 23:16                   ` Florian Friesdorf
2011-05-08 23:13                 ` [PATCH 1/2] style fixes Florian Friesdorf
2011-05-08 23:13                   ` [PATCH 2/2] test for sanitized notmuch-search output Florian Friesdorf
2011-05-08 23:58           ` [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search Jameson Graef Rollins

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='BANLkTi=ta-abS09Wa7=2_k7Q307u_Y4A0Q@mail.gmail.com' \
    --to=amdragon@mit.edu \
    --cc=a.amann@ucc.ie \
    --cc=flo@chaoflow.net \
    --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).