Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 65912429E20 for ; Sun, 8 May 2011 14:40:56 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zHw+IKJdQqSS for ; Sun, 8 May 2011 14:40:55 -0700 (PDT) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 4AE71431FB5 for ; Sun, 8 May 2011 14:40:55 -0700 (PDT) Received: by qyg14 with SMTP id 14so3973688qyg.5 for ; Sun, 08 May 2011 14:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=S8gzT71XuMiOkXHyWTYqhb3Y/6Zzo4sfdXx+BmPBdqA=; b=LBaXcMwaaO2Iah8qfN6dJgLoNbhXGspHCwF9JWBi2dTE0E/itqaB4iLV0xf/cjOf4Y p215+QWIP395hZ/VsY0xgEY+zTK7jOIjDetuGseaUxel17c6XgodayJdBn1UTmLdEtin o8iZI15SJsacofYmM8u8aD8JFpYDPERdUa7Ok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=VLfQ05ZFhkyK9qOYBdSfqyhccCX/R7bMWNOrkcY7slnjCJfC6JVsiOT+P6uA90WXV3 llWagUSHPN3JDRqO+esEQ1T6LmgcX/3oiNeJ5q7edd91xKXXhqIuUdKcN2jdrQcnqlFC eMiGYL0sUMDmsY1jbj5MW4exgYaF7q1Ta+XEI= MIME-Version: 1.0 Received: by 10.229.128.158 with SMTP id k30mr4525322qcs.188.1304890854510; Sun, 08 May 2011 14:40:54 -0700 (PDT) Sender: amdragon@gmail.com Received: by 10.229.233.17 with HTTP; Sun, 8 May 2011 14:40:54 -0700 (PDT) In-Reply-To: <1304889273-24560-2-git-send-email-flo@chaoflow.net> References: <87liyjgvyw.fsf@servo.factory.finestructure.net> <1304889273-24560-1-git-send-email-flo@chaoflow.net> <1304889273-24560-2-git-send-email-flo@chaoflow.net> Date: Sun, 8 May 2011 17:40:54 -0400 X-Google-Sender-Auth: DPj0sST1ZtUPKyRBYQo_9t4TcNo Message-ID: Subject: Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search From: Austin Clements To: Florian Friesdorf Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: notmuch@notmuchmail.org, Andreas Amann X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 May 2011 21:40:56 -0000 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 wrote: > From: Andreas Amann > > 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. > --- > =A0notmuch-search.c | =A0 22 ++++++++++++++++++++-- > =A01 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), > =A0 =A0 printf ("%s%s", item_type, item_id); > =A0} > > +static char * > +sanitize_string(const void *ctx, const char *str) > +{ > + =A0 =A0char *out, *loop; > + > + =A0 =A0loop =3D out =3D talloc_strdup (ctx, str); > + > + =A0 =A0for(;*loop;loop++){ > + =A0 =A0 =A0 if ((unsigned char)(*loop) < 32) > + =A0 =A0 =A0 =A0 =A0 *loop =3D '?'; > + =A0 =A0} > + =A0 =A0return out; > +} > + > =A0static void > =A0format_thread_text (const void *ctx, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *thread_id, > @@ -120,13 +134,17 @@ format_thread_text (const void *ctx, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *authors, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *subject) > =A0{ > + =A0 =A0void *ctx_quote =3D talloc_new (ctx); > + > =A0 =A0 printf ("thread:%s %12s [%d/%d] %s; %s", > =A0 =A0 =A0 =A0 =A0 =A0thread_id, > =A0 =A0 =A0 =A0 =A0 =A0notmuch_time_relative_date (ctx, date), > =A0 =A0 =A0 =A0 =A0 =A0matched, > =A0 =A0 =A0 =A0 =A0 =A0total, > - =A0 =A0 =A0 =A0 =A0 authors, > - =A0 =A0 =A0 =A0 =A0 subject); > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, authors), > + =A0 =A0 =A0 =A0 =A0 sanitize_string(ctx_quote, subject)); > + > + =A0 =A0talloc_free (ctx_quote); > =A0} > > =A0static void > -- > 1.7.5.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch >