unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] search --format=sanitized_text
@ 2011-05-06 23:17 Florian Friesdorf
  2011-05-06 23:17 ` [PATCH] implement search --format=sanitized_text + emacs UI to use it Florian Friesdorf
  0 siblings, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-06 23:17 UTC (permalink / raw)
  To: notmuch; +Cc: a.amann

In the release-candidate/0.6, the emacs UI is still not able to handle
messages where control characters are contained in the Subject: or
Author: fields.

As suggested by Pieter Prat, I turned Andreas Amann's patch into a
separate format.

The patch works and is very useful for me.

Is the general direction good?
What would be needed to get this included?

Florian Friesdorf (1):
  implement search --format=sanitized_text + emacs UI to use it

 emacs/notmuch.el |    3 +-
 notmuch-search.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)

-- 
1.7.5.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] implement search --format=sanitized_text + emacs UI to use it
  2011-05-06 23:17 [PATCH] search --format=sanitized_text Florian Friesdorf
@ 2011-05-06 23:17 ` Florian Friesdorf
  2011-05-06 23:55   ` Austin Clements
  0 siblings, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-06 23:17 UTC (permalink / raw)
  To: notmuch; +Cc: a.amann

Sanitize "Subject:" and "Author:" fields to not contain control
characters for sanitized_text format.

When a Subject field contains 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 for the sanitized_text
format. The emacs UI uses this format.

Thank you to Andreas Amann <a.amann@ucc.ie>, who wrote the initial
patch, I just turned it into a new format.

missing:
- man page update
- test, (works for me)
- investigate initialization warning:
CC -O2 notmuch-search.o
notmuch-search.c:98:1: warning: missing initializer
notmuch-search.c:98:1: warning: (near initialization for
'format_sanitized_text.results_null')
---
 emacs/notmuch.el |    3 +-
 notmuch-search.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1d683f8..9d7c212 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -879,7 +879,8 @@ The optional parameters are used as follows:
 		     (if oldest-first
 			 "--sort=oldest-first"
 		       "--sort=newest-first")
-		     query)))
+                     "--format=sanitized_text"
+                     query)))
 	  (set-process-sentinel proc 'notmuch-search-process-sentinel)
 	  (set-process-filter proc 'notmuch-search-process-filter))))
     (run-hooks 'notmuch-search-hook)))
diff --git a/notmuch-search.c b/notmuch-search.c
index 5e39511..d59dc44 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -78,6 +78,26 @@ static const search_format_t format_text = {
 };
 
 static void
+format_thread_sanitized_text (const void *ctx,
+			      const char *thread_id,
+			      const time_t date,
+			      const int matched,
+			      const int total,
+			      const char *authors,
+			      const char *subject);
+static const search_format_t format_sanitized_text = {
+    "",
+	"",
+	    format_item_id_text,
+	    format_thread_sanitized_text,
+	    " (",
+		"%s", " ",
+	    ")", "\n",
+	"",
+    "",
+};
+
+static void
 format_item_id_json (const void *ctx,
 		     const char *item_type,
 		     const char *item_id);
@@ -129,6 +149,42 @@ format_thread_text (const void *ctx,
 	    subject);
 }
 
+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_sanitized_text (const void *ctx,
+			      const char *thread_id,
+			      const time_t date,
+			      const int matched,
+			      const int total,
+			      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,
+	    sanitize_string(ctx_quote, authors),
+	    sanitize_string(ctx_quote, subject));
+
+    talloc_free (ctx_quote);
+}
+
 static void
 format_item_id_json (const void *ctx,
 		     unused (const char *item_type),
@@ -378,6 +434,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
 	    opt = argv[i] + sizeof ("--format=") - 1;
 	    if (strcmp (opt, "text") == 0) {
 		format = &format_text;
+	    } else if (strcmp (opt, "sanitized_text") == 0) {
+		format = &format_sanitized_text;
 	    } else if (strcmp (opt, "json") == 0) {
 		format = &format_json;
 	    } else {
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] implement search --format=sanitized_text + emacs UI to use it
  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
  0 siblings, 2 replies; 17+ messages in thread
From: Austin Clements @ 2011-05-06 23:55 UTC (permalink / raw)
  To: Florian Friesdorf; +Cc: notmuch, a.amann

Perhaps text summary output should *always* do this.  The text summary
format is meant half for user consumption and half for emacs
consumption and allowing newlines that don't indicate the end of a
summary line seems bad for *both* use cases.

On Fri, May 6, 2011 at 7:17 PM, Florian Friesdorf <flo@chaoflow.net> wrote:
> Sanitize "Subject:" and "Author:" fields to not contain control
> characters for sanitized_text format.
>
> When a Subject field contains 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 for the sanitized_text
> format. The emacs UI uses this format.
>
> Thank you to Andreas Amann <a.amann@ucc.ie>, who wrote the initial
> patch, I just turned it into a new format.
>
> missing:
> - man page update
> - test, (works for me)
> - investigate initialization warning:
> CC -O2 notmuch-search.o
> notmuch-search.c:98:1: warning: missing initializer
> notmuch-search.c:98:1: warning: (near initialization for
> 'format_sanitized_text.results_null')
> ---
>  emacs/notmuch.el |    3 +-
>  notmuch-search.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 60 insertions(+), 1 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 1d683f8..9d7c212 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -879,7 +879,8 @@ The optional parameters are used as follows:
>                     (if oldest-first
>                         "--sort=oldest-first"
>                       "--sort=newest-first")
> -                    query)))
> +                     "--format=sanitized_text"
> +                     query)))
>          (set-process-sentinel proc 'notmuch-search-process-sentinel)
>          (set-process-filter proc 'notmuch-search-process-filter))))
>     (run-hooks 'notmuch-search-hook)))
> diff --git a/notmuch-search.c b/notmuch-search.c
> index 5e39511..d59dc44 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -78,6 +78,26 @@ static const search_format_t format_text = {
>  };
>
>  static void
> +format_thread_sanitized_text (const void *ctx,
> +                             const char *thread_id,
> +                             const time_t date,
> +                             const int matched,
> +                             const int total,
> +                             const char *authors,
> +                             const char *subject);
> +static const search_format_t format_sanitized_text = {
> +    "",
> +       "",
> +           format_item_id_text,
> +           format_thread_sanitized_text,
> +           " (",
> +               "%s", " ",
> +           ")", "\n",
> +       "",
> +    "",
> +};
> +
> +static void
>  format_item_id_json (const void *ctx,
>                     const char *item_type,
>                     const char *item_id);
> @@ -129,6 +149,42 @@ format_thread_text (const void *ctx,
>            subject);
>  }
>
> +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_sanitized_text (const void *ctx,
> +                             const char *thread_id,
> +                             const time_t date,
> +                             const int matched,
> +                             const int total,
> +                             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,
> +           sanitize_string(ctx_quote, authors),
> +           sanitize_string(ctx_quote, subject));
> +
> +    talloc_free (ctx_quote);
> +}
> +
>  static void
>  format_item_id_json (const void *ctx,
>                     unused (const char *item_type),
> @@ -378,6 +434,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
>            opt = argv[i] + sizeof ("--format=") - 1;
>            if (strcmp (opt, "text") == 0) {
>                format = &format_text;
> +           } else if (strcmp (opt, "sanitized_text") == 0) {
> +               format = &format_sanitized_text;
>            } else if (strcmp (opt, "json") == 0) {
>                format = &format_json;
>            } else {
> --
> 1.7.5.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] implement search --format=sanitized_text + emacs UI to use it
  2011-05-06 23:55   ` Austin Clements
@ 2011-05-07  0:15     ` Florian Friesdorf
  2011-05-07  1:06     ` Jameson Graef Rollins
  1 sibling, 0 replies; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-07  0:15 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch, a.amann

[-- Attachment #1: Type: text/plain, Size: 771 bytes --]

On Fri, 6 May 2011 19:55:26 -0400, Austin Clements <amdragon@mit.edu> wrote:
> Perhaps text summary output should *always* do this.  The text summary
> format is meant half for user consumption and half for emacs
> consumption and allowing newlines that don't indicate the end of a
> summary line seems bad for *both* use cases.

reference to the original patch, that does that:
id: 8739ljwy7z.fsf@msstf091.ucc.ie

I'm just realizing, that it would have been good to send the patches
with git send-email as an answer to the original patch. Sorry for that,
still learning.

-- 
Florian Friesdorf <flo@chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] implement search --format=sanitized_text + emacs UI to use it
  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-08 21:14       ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
  1 sibling, 2 replies; 17+ messages in thread
From: Jameson Graef Rollins @ 2011-05-07  1:06 UTC (permalink / raw)
  To: Austin Clements, Florian Friesdorf; +Cc: notmuch, a.amann

[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

On Fri, 6 May 2011 19:55:26 -0400, Austin Clements <amdragon@mit.edu> wrote:
> Perhaps text summary output should *always* do this.  The text summary
> format is meant half for user consumption and half for emacs
> consumption and allowing newlines that don't indicate the end of a
> summary line seems bad for *both* use cases.

Hi, Florian.  I think I agree with Austin here that the text output
should probably just always be sanitized.  Can you try sending in a
patch that just automatically sanitizes the text output?

Also, I believe that this patch is not entirely compatible with the
current head of the release-candidate/0.6 branch.  I pushed a patch to
that branch to fix a search output formatting bug, and in so doing I
added a field to the search_format struct.

If you could make those changes and post a new patch that would be
great.  Thanks.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] implement search --format=sanitized_text + emacs UI to use it
  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
  1 sibling, 1 reply; 17+ messages in thread
From: Pieter Praet @ 2011-05-07  9:14 UTC (permalink / raw)
  To: Jameson Graef Rollins, Austin Clements, Florian Friesdorf
  Cc: notmuch, a.amann

On Fri, 06 May 2011 18:06:47 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
> On Fri, 6 May 2011 19:55:26 -0400, Austin Clements <amdragon@mit.edu> wrote:
> > Perhaps text summary output should *always* do this.  The text summary
> > format is meant half for user consumption and half for emacs
> > consumption and allowing newlines that don't indicate the end of a
> > summary line seems bad for *both* use cases.
> 
> Hi, Florian.  I think I agree with Austin here that the text output
> should probably just always be sanitized.  Can you try sending in a
> patch that just automatically sanitizes the text output?

Indeed, Andreas and I agreed [1] as well that sanitization should be
default for search, yet optional for show.

> Also, I believe that this patch is not entirely compatible with the
> current head of the release-candidate/0.6 branch.  I pushed a patch to
> that branch to fix a search output formatting bug, and in so doing I
> added a field to the search_format struct.
> 
> If you could make those changes and post a new patch that would be
> great.  Thanks.
> 
> jamie.
Non-text part: application/pgp-signature
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

Peace

-- 
Pieter


[1] id:"87pqokx7op.fsf@A7GMS.i-did-not-set--mail-host-address--so-tickle-me"

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] implement search --format=sanitized_text + emacs UI to use it
  2011-05-07  9:14       ` Pieter Praet
@ 2011-05-07  9:25         ` Pieter Praet
  0 siblings, 0 replies; 17+ messages in thread
From: Pieter Praet @ 2011-05-07  9:25 UTC (permalink / raw)
  To: Jameson Graef Rollins, Austin Clements, Florian Friesdorf
  Cc: notmuch, a.amann

On Sat, 07 May 2011 11:14:08 +0200, Pieter Praet <pieter@praet.org> wrote:
> On Fri, 06 May 2011 18:06:47 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
> > On Fri, 6 May 2011 19:55:26 -0400, Austin Clements <amdragon@mit.edu> wrote:
> > > Perhaps text summary output should *always* do this.  The text summary
> > > format is meant half for user consumption and half for emacs
> > > consumption and allowing newlines that don't indicate the end of a
> > > summary line seems bad for *both* use cases.
> > 
> > Hi, Florian.  I think I agree with Austin here that the text output
> > should probably just always be sanitized.  Can you try sending in a
> > patch that just automatically sanitizes the text output?
> 
> Indeed, Andreas and I agreed [1] as well that sanitization should be
> default for search, yet optional for show.
> 
> > Also, I believe that this patch is not entirely compatible with the
> > current head of the release-candidate/0.6 branch.  I pushed a patch to
> > that branch to fix a search output formatting bug, and in so doing I
> > added a field to the search_format struct.
> > 
> > If you could make those changes and post a new patch that would be
> > great.  Thanks.
> > 
> > jamie.
> Non-text part: application/pgp-signature
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> 
> Peace
> 
> -- 
> Pieter
> 
> 
> [1] id:"87pqokx7op.fsf@A7GMS.i-did-not-set--mail-host-address--so-tickle-me"

... and apparently that never reached the list since his reply was
addressed at me personally, so I've forwarded it: 87mxiykgu3.fsf@praet.org


Peace

-- 
Pieter

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] sanitize notmuch-search output - rewrapped
  2011-05-07  1:06     ` Jameson Graef Rollins
  2011-05-07  9:14       ` Pieter Praet
@ 2011-05-08 21:14       ` Florian Friesdorf
  2011-05-08 21:14         ` [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search Florian Friesdorf
  1 sibling, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 21:14 UTC (permalink / raw)
  To: notmuch

patch applies to current rc (ed6d3b8bb727b3acaa913945d6edf29843ab0864)
and works for me. It's the Andreas' patch just sent, that the commit
message will make it when applied with 'git am'.

Andreas Amann (1):
  Sanitize "Subject:" and "Author:" fields to not contain control
    characters in notmuch-search

 notmuch-search.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

-- 
1.7.5.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
  2011-05-08 21:14       ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
@ 2011-05-08 21:14         ` Florian Friesdorf
  2011-05-08 21:40           ` Austin Clements
  2011-05-08 23:58           ` [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search Jameson Graef Rollins
  0 siblings, 2 replies; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 21:14 UTC (permalink / raw)
  To: notmuch; +Cc: Andreas Amann

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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
  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
  2011-05-08 21:54             ` Florian Friesdorf
  2011-05-08 23:58           ` [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search Jameson Graef Rollins
  1 sibling, 1 reply; 17+ messages in thread
From: Austin Clements @ 2011-05-08 21:40 UTC (permalink / raw)
  To: Florian Friesdorf; +Cc: notmuch, Andreas Amann

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
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
  2011-05-08 21:40           ` Austin Clements
@ 2011-05-08 21:54             ` Florian Friesdorf
  2011-05-08 22:02               ` Austin Clements
  0 siblings, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 21:54 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch, Andreas Amann

[-- Attachment #1: Type: text/plain, Size: 908 bytes --]

On Sun, 8 May 2011 17:40:54 -0400, Austin Clements <amdragon@mit.edu> wrote:
> 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.

fixed

> Relatedly, "for(;*loop;loop++){" should be spaced out
> like "for (; *loop; loop++) {".

fixed

> (..) 
> Also, existing code conventionally uses a variable named "local"
> for function-level talloc contexts such as your ctx_quote.

In notmuch-search.c there is no variable named "local", in the other
functions its also named ctx_quote. Should I rename all ctx_quote to
"local"?

Will send style fixes after we cleared this.

-- 
Florian Friesdorf <flo@chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
  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:13                 ` [PATCH 1/2] style fixes Florian Friesdorf
  0 siblings, 2 replies; 17+ messages in thread
From: Austin Clements @ 2011-05-08 22:02 UTC (permalink / raw)
  To: Florian Friesdorf; +Cc: notmuch, Andreas Amann

On Sun, May 8, 2011 at 5:54 PM, Florian Friesdorf <flo@chaoflow.net> wrote:
> On Sun, 8 May 2011 17:40:54 -0400, Austin Clements <amdragon@mit.edu> wrote:
>> Also, existing code conventionally uses a variable named "local"
>> for function-level talloc contexts such as your ctx_quote.
>
> In notmuch-search.c there is no variable named "local", in the other
> functions its also named ctx_quote. Should I rename all ctx_quote to
> "local"?

Huh, sure enough.  Looks like the library uses "local" consistently,
but the CLI uses ctx_quote multiple times and "local" appears only
once, so, yeah, stick with ctx_quote.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] sanitize notmuch-search output - rewrapped
  2011-05-08 22:02               ` Austin Clements
@ 2011-05-08 23:12                 ` Florian Friesdorf
  2011-05-08 23:16                   ` Florian Friesdorf
  2011-05-08 23:13                 ` [PATCH 1/2] style fixes Florian Friesdorf
  1 sibling, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 23:12 UTC (permalink / raw)
  To: notmuch

patch applies to current rc (ed6d3b8bb727b3acaa913945d6edf29843ab0864)
and works for me. It's the Andreas' patch just sent, that the commit
message will make it when applied with 'git am'.

Andreas Amann (1):
  Sanitize "Subject:" and "Author:" fields to not contain control
    characters in notmuch-search

 notmuch-search.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

-- 
1.7.5.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/2] style fixes
  2011-05-08 22:02               ` Austin Clements
  2011-05-08 23:12                 ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
@ 2011-05-08 23:13                 ` Florian Friesdorf
  2011-05-08 23:13                   ` [PATCH 2/2] test for sanitized notmuch-search output Florian Friesdorf
  1 sibling, 1 reply; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 23:13 UTC (permalink / raw)
  To: notmuch

---
 notmuch-search.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index e7fc41a..fd7c7d1 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -112,13 +112,13 @@ format_item_id_text (unused (const void *ctx),
 }
 
 static char *
-sanitize_string(const void *ctx, const char *str)
+sanitize_string (const void *ctx, const char *str)
 {
     char *out, *loop;
 
     loop = out = talloc_strdup (ctx, str);
 
-    for(;*loop;loop++){
+    for (; *loop; loop++) {
 	if ((unsigned char)(*loop) < 32)
 	    *loop = '?';
     }
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/2] test for sanitized notmuch-search output
  2011-05-08 23:13                 ` [PATCH 1/2] style fixes Florian Friesdorf
@ 2011-05-08 23:13                   ` Florian Friesdorf
  0 siblings, 0 replies; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 23:13 UTC (permalink / raw)
  To: notmuch

---
 test/corpus.ccs/cur/1:2, |    8 ++++++++
 test/search-output       |    8 ++++++++
 test/test-lib.sh         |   12 ++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 test/corpus.ccs/cur/1:2,

diff --git a/test/corpus.ccs/cur/1:2, b/test/corpus.ccs/cur/1:2,
new file mode 100644
index 0000000..60081c4
--- /dev/null
+++ b/test/corpus.ccs/cur/1:2,
@@ -0,0 +1,8 @@
+From: "Two =?ISO-8859-1?Q?line=0A_author?=" <two@lineauthor.net>
+To: notmuch@notmuchmail.org
+Date: Tue, 17 Nov 2009 21:28:37 +0600
+Subject: [notmuch] two =?ISO-8859-1?Q?line=0A_subject?=
+	headers
+Message-ID: <123>
+
+body
diff --git a/test/search-output b/test/search-output
index 33ae119..202c13e 100755
--- a/test/search-output
+++ b/test/search-output
@@ -316,4 +316,12 @@ cat <<EOF >EXPECTED
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
+test_begin_subtest "notmuch search for message with quoted-printable line-breaks in author and subject"
+add_email_corpus_control_char_subject
+notmuch search "*" > OUTPUT
+cat <<EOF >EXPECTED
+thread:0000000000000001   2009-11-17 [1/1] Two line? author; [notmuch] two line? subject headers (inbox unread)
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
 test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index eaf5051..0990d91 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -417,6 +417,18 @@ add_email_corpus ()
     fi
 }
 
+add_email_corpus_control_char_subject ()
+{
+    rm -rf ${MAIL_DIR}
+    if [ -d ../corpus.ccs.mail ]; then
+        cp -a ../corpus.ccs.mail ${MAIL_DIR}
+    else
+        cp -a ../corpus.ccs ${MAIL_DIR}
+        notmuch new >/dev/null
+        cp -a ${MAIL_DIR} ../corpus.ccs.mail
+    fi
+}
+
 test_begin_subtest ()
 {
     if [ -n "$inside_subtest" ]; then
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] sanitize notmuch-search output - rewrapped
  2011-05-08 23:12                 ` [PATCH] sanitize notmuch-search output - rewrapped Florian Friesdorf
@ 2011-05-08 23:16                   ` Florian Friesdorf
  0 siblings, 0 replies; 17+ messages in thread
From: Florian Friesdorf @ 2011-05-08 23:16 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]


this went out erroneously.

On Mon,  9 May 2011 01:12:19 +0200, Florian Friesdorf <flo@chaoflow.net> wrote:
> patch applies to current rc (ed6d3b8bb727b3acaa913945d6edf29843ab0864)
> and works for me. It's the Andreas' patch just sent, that the commit
> message will make it when applied with 'git am'.
> 
> Andreas Amann (1):
>   Sanitize "Subject:" and "Author:" fields to not contain control
>     characters in notmuch-search
> 
>  notmuch-search.c |   22 ++++++++++++++++++++--
>  1 files changed, 20 insertions(+), 2 deletions(-)
> 
> -- 
> 1.7.5.1
> 

-- 
Florian Friesdorf <flo@chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search
  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
@ 2011-05-08 23:58           ` Jameson Graef Rollins
  1 sibling, 0 replies; 17+ messages in thread
From: Jameson Graef Rollins @ 2011-05-08 23:58 UTC (permalink / raw)
  To: Florian Friesdorf, notmuch; +Cc: Andreas Amann

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Hey, Florian.  I applied this patch to release-candidate/0.6, manually
adding in the formatting fixes in the same patch.

I also applied the test patch, modified to use the add_message test
suite function, which makes the patch a bit simpler.

Thanks for the fixes.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-05-08 23:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).