[PATCH] sanitize notmuch-search output - rewrapped

2011-05-08 Thread Florian Friesdorf
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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Florian Friesdorf
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.
---
 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


Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Austin Clements
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.
> ---
>  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
>
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Florian Friesdorf
On Sun, 8 May 2011 17:40:54 -0400, Austin Clements  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 
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: f...@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC


pgpWtUE1HeJND.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Austin Clements
On Sun, May 8, 2011 at 5:54 PM, Florian Friesdorf  wrote:
> On Sun, 8 May 2011 17:40:54 -0400, Austin Clements  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.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Fri, 6 May 2011 22:31:09 -0400, Tim Gray  wrote:
> Ditto with the very very simple patch I sent about OS X compiling.  I 
> take it there are few users of OS X on this list, so every little bit 
> could help.

Hi, Tim.  Have you tried compiling the release-candidate/0.6 on OS X
without this patch?  I fixed an issue with the library linking that
could have also been the source of the issue you're seeing.

If release-candidate/0.6 still requires your patch to build, if you
could rebase your patch against the head of release-candidate/0.6 I'll
look at applying it again (it wasn't applying cleanly against the
current head of that branch).

Thanks.

jamie.


pgpBPMlBt8flX.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] sanitize notmuch-search output - rewrapped

2011-05-08 Thread Florian Friesdorf
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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] style fixes

2011-05-08 Thread Florian Friesdorf
---
 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

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] test for sanitized notmuch-search output

2011-05-08 Thread Florian Friesdorf
---
 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 000..60081c4
--- /dev/null
+++ b/test/corpus.ccs/cur/1:2,
@@ -0,0 +1,8 @@
+From: "Two =?ISO-8859-1?Q?line=0A_author?=" 
+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  OUTPUT
+cat /dev/null
+cp -a ${MAIL_DIR} ../corpus.ccs.mail
+fi
+}
+
 test_begin_subtest ()
 {
 if [ -n "$inside_subtest" ]; then
-- 
1.7.5.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] sanitize notmuch-search output - rewrapped

2011-05-08 Thread Florian Friesdorf

this went out erroneously.

On Mon,  9 May 2011 01:12:19 +0200, Florian Friesdorf  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 
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: f...@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC


pgpFsrBmCtBfe.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Add part filename in notmuch show output if available.

2011-05-08 Thread Jameson Graef Rollins
On Sun,  8 May 2011 03:00:37 +0400, Dmitry Kurochkin 
 wrote:
> Before the change, notmuch show output had filename only for
> parts with "Content-Disposition: attachment".  But parts with
> inline disposition may have filename as well.
> 
> The patch makes notmuch show always output filename if available,
> independent of Content-Disposition.  Both JSON and text output
> formats are changed.

Hey, Dimitry.  I think this is a nice idea, and a clean patch.

It's now applied to the release-candidate/0.6 branch.

jamie.


pgpq9uKC8T7hw.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Florian Friesdorf
On Sat, 07 May 2011 01:51:25 +0200, Florian Friesdorf  wrote:
> (..)
> An open issue (also with gmime 2.4.24) is the extraction of a PDF from
> an encrypted message via emacs (discussed on irc before, mentioned here
> for completeness of the 

In the current release candidate this got fixed by Jamie.

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


pgpTTNLEBFVIg.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Jameson Graef Rollins
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.


pgpSo56tz6dHL.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Fri, 06 May 2011 19:56:30 -0400, James Vasile  
wrote:
> I sent two patches to the list on March 16.  They were a bug fix to
> allow notmuch to correctly handle some poorly formatted email.  Nobody
> ever replied, but I'd like to see the bug fixed nonetheless, as it
> results in unreadable mail.  Since I've actually seen such mail in the
> wild, I'd like to see Notmuch handle it.

Hey, James.  Florian Friesdorf sent in a patch to sanitize the output of
notmuch search, which I think is the issue that you're patches were also
dealing with.  Florian's patch has be pushed to my
release-candidate/0.6.  Can you see if your issue is fixed there?  If
not maybe you could try submitting a new patch that would apply to the
release-candidate/0.6 head.

Thanks.

jamie.


pgpqYXFj9fIal.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
Hi, folks.  I've pushed some more patches to the release-candidate/0.6
branch [0] (which should now be at commit id
89ca01b6104dd732903104e50777a7b4a211e1f4):

* support for decryption of parts with notmuch show --format=part
* emacs support for retrieving parts (like attachments) from encrypted
  messages
* Dmitry Kurochkin's patch to include filenames for inline attachments
* Andreas Amann and Florian's patch for sanitizing search text output
* various other cleanups

Dmitry Kurochkin have also asked for some patches to be applied dealing
with fcc paths.  I haven't dealt with that yet, since it doesn't apply
cleanly against the branch head and the patch is too large for me to
resolve easily.  If someone ones to take a crack at fixing those issues
up for the next release that would be great.

Please keep using the head of this branch, and report any issues, and
hopefully we'll be able to push it out soon.

jamie.

[0] git://finestructure.net/notmuch release-candidate/0.6


pgpcqw1syIAmQ.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Daniel Kahn Gillmor
On 05/08/2011 09:03 PM, Jameson Graef Rollins wrote:
> Hi, folks.  I've pushed some more patches to the release-candidate/0.6
> branch [0] (which should now be at commit id
> 89ca01b6104dd732903104e50777a7b4a211e1f4):
> 
> * support for decryption of parts with notmuch show --format=part
> * emacs support for retrieving parts (like attachments) from encrypted
>   messages
> * Dmitry Kurochkin's patch to include filenames for inline attachments
> * Andreas Amann and Florian's patch for sanitizing search text output
> * various other cleanups

I'm running this now.  It's great.  Thank you, Jamie!

One new feature that you didn't mention is that --decrypt is passed
through to notmuch reply based on the state of the current buffer.

That is: it used to be that you had to remember whether you'd viewed a
thread with M-RET or RET (to trigger decryption+verification) and adjust
your reply invocation to match if you wanted proper quoting and
attribution when replying to encrypted mail.

Now it Just Works™.  Excellent Work.

--dkg



signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Sun, 08 May 2011 21:24:52 -0400, Daniel Kahn Gillmor 
 wrote:
> One new feature that you didn't mention is that --decrypt is passed
> through to notmuch reply based on the state of the current buffer.
> 
> That is: it used to be that you had to remember whether you'd viewed a
> thread with M-RET or RET (to trigger decryption+verification) and adjust
> your reply invocation to match if you wanted proper quoting and
> attribution when replying to encrypted mail.

Thanks for point that out, dkg.  I did forget to mention that.

Now we just need to figure out how to auto-encrypt replies to encrypted
messages...

jamie.


pgpHIViE8shSH.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: storing From and Subject in xapian

2011-05-08 Thread Jameson Graef Rollins
On Wed, 4 May 2011 21:48:39 -0400, Austin Clements  wrote:
> This is awesome.  What was your machine configuration?

Does anyone else have an opinions about this patch?  It seems reasonable
to me (other than a couple errant comments that were left in and should
be removed).  It seems worth the slight increase in database size for
such a nice performance improvement.

Unless I hear a strong positive response I'll hold off on considering it
for 0.6, and suggest instead targeting it for 0.7.

jamie.


pgppzsKVItXSD.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/1] emacs: Use "message-cited-text" instead of "message-cited-text-face"

2011-05-08 Thread Jameson Graef Rollins
Hi, Pieter.  I applied this patch to the release-candidate/0.6 branch.
Thanks for sending it in, and fixing it up.

jamie.


pgpbyIwoInDUg.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: storing From and Subject in xapian

2011-05-08 Thread Istvan Marko
Jameson Graef Rollins  writes:

> Unless I hear a strong positive response I'll hold off on considering it
> for 0.6, and suggest instead targeting it for 0.7.

I would say wait until 0.7 at least.

An important thing missing is fallback to the old method for messages
where the Subject/From VALUE fields don't exist. Otherwise people will
get blank results until they rebuild their database.

-- 
Istvan
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] lib/message-file: plug three memleaks.

2011-05-08 Thread Anton Khirnov
On Fri, 15 Apr 2011 16:43:58 +0200, Anton Khirnov  wrote:
> ---
>  lib/message-file.c |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/message-file.c b/lib/message-file.c
> index 7722832..b7b3286 100644
> --- a/lib/message-file.c
> +++ b/lib/message-file.c
> @@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t 
> *message,
>   strncpy(combined_header,header_sofar,hdrsofar);
>   *(combined_header+hdrsofar) = ' ';
>   strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
> + free(decoded_value);
>   g_hash_table_insert (message->headers, header, combined_header);
>   }
>   } else {
>   if (header_sofar == NULL) {
>   /* Only insert if we don't have a value for this header, yet. */
>   g_hash_table_insert (message->headers, header, decoded_value);
> + } else {
> + free(header);
> + free(decoded_value);
> + decoded_value = header_sofar;
>   }
>   }
>   /* if we found a match we can bail - unless of course we are
> -- 
> 1.7.4.1
> 
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

ping

--
Anton Khirnov
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


release-candidate/0.6

2011-05-08 Thread Dmitry Kurochkin
Hi Jameson.

First of all, thank you for your effort on notmuch.  It is a great
project and I am happy to see it going forward (again)!

Can we include FCC fix in the 0.6 please?  It was broken in 0.5 (IIRC)
because of old configuration check.  There are two patches on the ML to
address it.  The first one is from Carl
id:"1290632444-10046-1-git-send-email-cworth at cworth.org" where the check
is just commented out.  Another one is a proper fix from David
id:"1290682750-30283-2-git-send-email-dme at dme.org".  It is part of a
patch series that adds some ERT (Emacs Lisp Regression Testing) support.
I see few options: apply a "fix" from Carl, apply ERT patch series from
David, or factor out the proper fix from David's series and apply it
separately.  Not sure what is the best.  Perhaps David can comment about
the ERT stuff.  I am fine with any option, just do not leave it as is,
i.e. broken.  I am ready to help with the factoring out the proper fix,
if all agree it is the best solution and no one (David?) volunteers for
it.

Thank you,
  Dmitry


[PATCH] Add part filename in notmuch show output if available.

2011-05-08 Thread Dmitry Kurochkin
Before the change, notmuch show output had filename only for
parts with "Content-Disposition: attachment".  But parts with
inline disposition may have filename as well.

The patch makes notmuch show always output filename if available,
independent of Content-Disposition.  Both JSON and text output
formats are changed.

The main goal of these changes is to have filenames on Emacs
buttons for inline attachments.  In particular, this is very
helpful for inline patches.

Note: text format changes may require updates in clients that use
it.  The changes are:

* text part header format changed from:

^Lpart{ ID: 2, Content-type: text/x-diff

  to:

^Lpart{ ID: 2, Content-type: text/x-diff, Filename: cool-feature.patch

* attachment format changed from:

^Lattachment{ ID: 4, Content-type: application/octet-stream
Attachment: data.tar.bz2 (application/octet-stream)
^Lattachment}

  to:

^Lattachment{ ID: 4, Content-type: application/octet-stream
Attachment: data.tar.bz2
^Lattachment}
---
 notmuch-show.c |   25 +
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 4d64d1e..1624b23 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -411,6 +411,7 @@ format_part_text (GMimeObject *part,
 {
 GMimeContentDisposition *disposition;
 GMimeContentType *content_type;
+const char *filename;

 /* Avoid compiler complaints about unused arguments. */
 (void) first;
@@ -458,18 +459,19 @@ format_part_text (GMimeObject *part,
return;
 }

+filename = g_mime_part_get_filename (GMIME_PART (part));
+
 disposition = g_mime_object_get_content_disposition (part);
 if (disposition &&
strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
 {
-   const char *filename = g_mime_part_get_filename (GMIME_PART (part));
content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));

printf ("\fattachment{ ID: %d, Content-type: %s\n",
*part_count,
g_mime_content_type_to_string (content_type));
-   printf ("Attachment: %s (%s)\n", filename,
-   g_mime_content_type_to_string (content_type));
+   if (filename && *filename)
+   printf ("Attachment: %s\n", filename);

if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
@@ -487,9 +489,13 @@ format_part_text (GMimeObject *part,

 content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));

-printf ("\fpart{ ID: %d, Content-type: %s\n",
+printf ("\fpart{ ID: %d, Content-type: %s",
*part_count,
g_mime_content_type_to_string (content_type));
+if (filename && *filename)
+   printf (", Filename: %s\n", filename);
+else
+   printf ("\n");

 if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
@@ -583,12 +589,12 @@ format_part_json (GMimeObject *part,

 {
 GMimeContentType *content_type;
-GMimeContentDisposition *disposition;
 GError* err = NULL;
 void *ctx = talloc_new (NULL);
 GMimeStream *stream_memory = g_mime_stream_mem_new ();
 GByteArray *part_content;
 const char *cid;
+const char *filename;

 *part_count += 1;

@@ -722,14 +728,9 @@ format_part_json (GMimeObject *part,
return;
 }

-disposition = g_mime_object_get_content_disposition (part);
-if (disposition &&
-   strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
-{
-   const char *filename = g_mime_part_get_filename (GMIME_PART (part));
-
+filename = g_mime_part_get_filename (GMIME_PART (part));
+if (filename && *filename)
printf (", \"filename\": %s", json_quote_str (ctx, filename));
-}

 if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
-- 
1.7.5.1



[PATCH] Add part filename in notmuch show output if available.

2011-05-08 Thread Dmitry Kurochkin
Forgot to note, this patch is for release-candidate/0.6 branch.

Regards,
  Dmitry


[PATCH] sanitize notmuch-search output - rewrapped

2011-05-08 Thread Florian Friesdorf
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



[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Florian Friesdorf
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.
---
 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



[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Austin Clements
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.
> ---
> ?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 at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>


[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Florian Friesdorf
On Sun, 8 May 2011 17:40:54 -0400, Austin Clements  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 
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/b9b8fc88/attachment.pgp>


[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Austin Clements
On Sun, May 8, 2011 at 5:54 PM, Florian Friesdorf  wrote:
> On Sun, 8 May 2011 17:40:54 -0400, Austin Clements  
> 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.


release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Fri, 6 May 2011 22:31:09 -0400, Tim Gray  wrote:
> Ditto with the very very simple patch I sent about OS X compiling.  I 
> take it there are few users of OS X on this list, so every little bit 
> could help.

Hi, Tim.  Have you tried compiling the release-candidate/0.6 on OS X
without this patch?  I fixed an issue with the library linking that
could have also been the source of the issue you're seeing.

If release-candidate/0.6 still requires your patch to build, if you
could rebase your patch against the head of release-candidate/0.6 I'll
look at applying it again (it wasn't applying cleanly against the
current head of that branch).

Thanks.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/9c5d7417/attachment.pgp>


[PATCH] Add part filename in notmuch show output if available.

2011-05-08 Thread Jameson Graef Rollins
On Sun,  8 May 2011 03:00:37 +0400, Dmitry Kurochkin  wrote:
> Before the change, notmuch show output had filename only for
> parts with "Content-Disposition: attachment".  But parts with
> inline disposition may have filename as well.
> 
> The patch makes notmuch show always output filename if available,
> independent of Content-Disposition.  Both JSON and text output
> formats are changed.

Hey, Dimitry.  I think this is a nice idea, and a clean patch.

It's now applied to the release-candidate/0.6 branch.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/c7e290cf/attachment.pgp>


[PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search

2011-05-08 Thread Jameson Graef Rollins
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.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/037c2b99/attachment.pgp>


release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Fri, 06 May 2011 19:56:30 -0400, James Vasile  
wrote:
> I sent two patches to the list on March 16.  They were a bug fix to
> allow notmuch to correctly handle some poorly formatted email.  Nobody
> ever replied, but I'd like to see the bug fixed nonetheless, as it
> results in unreadable mail.  Since I've actually seen such mail in the
> wild, I'd like to see Notmuch handle it.

Hey, James.  Florian Friesdorf sent in a patch to sanitize the output of
notmuch search, which I think is the issue that you're patches were also
dealing with.  Florian's patch has be pushed to my
release-candidate/0.6.  Can you see if your issue is fixed there?  If
not maybe you could try submitting a new patch that would apply to the
release-candidate/0.6 head.

Thanks.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/d131916c/attachment.pgp>


release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
Hi, folks.  I've pushed some more patches to the release-candidate/0.6
branch [0] (which should now be at commit id
89ca01b6104dd732903104e50777a7b4a211e1f4):

* support for decryption of parts with notmuch show --format=part
* emacs support for retrieving parts (like attachments) from encrypted
  messages
* Dmitry Kurochkin's patch to include filenames for inline attachments
* Andreas Amann and Florian's patch for sanitizing search text output
* various other cleanups

Dmitry Kurochkin have also asked for some patches to be applied dealing
with fcc paths.  I haven't dealt with that yet, since it doesn't apply
cleanly against the branch head and the patch is too large for me to
resolve easily.  If someone ones to take a crack at fixing those issues
up for the next release that would be great.

Please keep using the head of this branch, and report any issues, and
hopefully we'll be able to push it out soon.

jamie.

[0] git://finestructure.net/notmuch release-candidate/0.6
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/0154722e/attachment-0001.pgp>


release-candidate/0.6

2011-05-08 Thread Daniel Kahn Gillmor
On 05/08/2011 09:03 PM, Jameson Graef Rollins wrote:
> Hi, folks.  I've pushed some more patches to the release-candidate/0.6
> branch [0] (which should now be at commit id
> 89ca01b6104dd732903104e50777a7b4a211e1f4):
> 
> * support for decryption of parts with notmuch show --format=part
> * emacs support for retrieving parts (like attachments) from encrypted
>   messages
> * Dmitry Kurochkin's patch to include filenames for inline attachments
> * Andreas Amann and Florian's patch for sanitizing search text output
> * various other cleanups

I'm running this now.  It's great.  Thank you, Jamie!

One new feature that you didn't mention is that --decrypt is passed
through to notmuch reply based on the state of the current buffer.

That is: it used to be that you had to remember whether you'd viewed a
thread with M-RET or RET (to trigger decryption+verification) and adjust
your reply invocation to match if you wanted proper quoting and
attribution when replying to encrypted mail.

Now it Just Works?.  Excellent Work.

--dkg

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1030 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/c8722d51/attachment.pgp>


release-candidate/0.6

2011-05-08 Thread Jameson Graef Rollins
On Sun, 08 May 2011 21:24:52 -0400, Daniel Kahn Gillmor  wrote:
> One new feature that you didn't mention is that --decrypt is passed
> through to notmuch reply based on the state of the current buffer.
> 
> That is: it used to be that you had to remember whether you'd viewed a
> thread with M-RET or RET (to trigger decryption+verification) and adjust
> your reply invocation to match if you wanted proper quoting and
> attribution when replying to encrypted mail.

Thanks for point that out, dkg.  I did forget to mention that.

Now we just need to figure out how to auto-encrypt replies to encrypted
messages...

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/cb6edf43/attachment.pgp>


storing From and Subject in xapian

2011-05-08 Thread Jameson Graef Rollins
On Wed, 4 May 2011 21:48:39 -0400, Austin Clements  wrote:
> This is awesome.  What was your machine configuration?

Does anyone else have an opinions about this patch?  It seems reasonable
to me (other than a couple errant comments that were left in and should
be removed).  It seems worth the slight increase in database size for
such a nice performance improvement.

Unless I hear a strong positive response I'll hold off on considering it
for 0.6, and suggest instead targeting it for 0.7.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/53077df9/attachment.pgp>


[PATCH 1/1] emacs: Use "message-cited-text" instead of "message-cited-text-face"

2011-05-08 Thread Jameson Graef Rollins
Hi, Pieter.  I applied this patch to the release-candidate/0.6 branch.
Thanks for sending it in, and fixing it up.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110508/5e49a4fa/attachment.pgp>


storing From and Subject in xapian

2011-05-08 Thread Istvan Marko
Jameson Graef Rollins  writes:

> Unless I hear a strong positive response I'll hold off on considering it
> for 0.6, and suggest instead targeting it for 0.7.

I would say wait until 0.7 at least.

An important thing missing is fallback to the old method for messages
where the Subject/From VALUE fields don't exist. Otherwise people will
get blank results until they rebuild their database.

-- 
Istvan