unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Michal Sojka <sojkam1@fel.cvut.cz>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them
Date: Fri, 24 Feb 2012 23:33:12 -0500	[thread overview]
Message-ID: <20120225043312.GL30513@mit.edu> (raw)
In-Reply-To: <1330068983-4483-1-git-send-email-sojkam1@fel.cvut.cz>

LGTM.  I'm assuming this interacts with the uuencoding filter in the
right order (I don't see how any other order could be correct), but
don't actually know.

Quoth Michal Sojka on Feb 24 at  8:36 am:
> This fixes a bug that didn't allow to search for non-ASCII words such
> parts. The code here was copied from show_text_part_content(), because
> the show command already does the needed conversion when showing the
> message.
> ---
>  lib/index.cc |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index d8f8b2b..e377732 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -315,6 +315,7 @@ _index_mime_part (notmuch_message_t *message,
>      GByteArray *byte_array;
>      GMimeContentDisposition *disposition;
>      char *body;
> +    const char *charset;
>  
>      if (! part) {
>  	fprintf (stderr, "Warning: Not indexing empty mime part.\n");
> @@ -390,6 +391,20 @@ _index_mime_part (notmuch_message_t *message,
>      g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
>  			      discard_uuencode_filter);
>  
> +    charset = g_mime_object_get_content_type_parameter (part, "charset");
> +    if (charset) {
> +	GMimeFilter *charset_filter;
> +	charset_filter = g_mime_filter_charset_new (charset, "UTF-8");
> +	/* This result can be NULL for things like "unknown-8bit".
> +	 * Don't set a NULL filter as that makes GMime print
> +	 * annoying assertion-failure messages on stderr. */
> +	if (charset_filter) {
> +	    g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
> +				      charset_filter);
> +	    g_object_unref (charset_filter);
> +	}
> +    }
> +
>      wrapper = g_mime_part_get_content_object (GMIME_PART (part));
>      if (wrapper)
>  	g_mime_data_wrapper_write_to_stream (wrapper, filter);

  parent reply	other threads:[~2012-02-26  5:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 17:10 Searching through different charsets Serge Z
2012-02-24  0:31 ` Michal Sojka
2012-02-24  0:33   ` [PATCH] test: Add test for searching of uncommonly encoded messages Michal Sojka
2012-02-24  4:29     ` Serge Z
2012-02-24  7:00       ` Michal Sojka
2012-02-24  7:57         ` Serge Z
2012-02-24  8:38           ` Michal Sojka
2012-02-25  8:36             ` Serge Z
2012-02-26  9:33               ` Double decoded text/html parts (was: [PATCH] test: Add test for searching of uncommonly encoded messages) Michal Sojka
2012-02-26 10:20                 ` Serge Z
2012-02-24  7:36     ` [PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them Michal Sojka
2012-02-24  7:36       ` [PATCH 2/2] test: Remove 'broken' flag from encoding test Michal Sojka
2012-02-25  4:33       ` Austin Clements [this message]
2012-02-29 11:55       ` [PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them David Bremner
2012-02-29 11:55     ` [PATCH] test: Add test for searching of uncommonly encoded messages David Bremner

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=20120225043312.GL30513@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    --cc=sojkam1@fel.cvut.cz \
    /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).