X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-index-message.cc;h=79ec81e40c50a956d510980be5bf4682666fffbf;hp=5396cd19458fe0b5fc2833545da9aa6b7c345fe0;hb=784779fb6759a0a3990604befeb5e5ee7e7d1145;hpb=870b3987265f74ed8b45ba0e7d7edfcca1923b5a diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index 5396cd19..79ec81e4 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -379,8 +379,8 @@ gen_terms_body_str (Xapian::TermGenerator term_gen, } line_end = next_line - 1; - /* Trim whitespace. */ - while (*next_line && isspace (*next_line)) + /* Get to the next non-blank line. */ + while (*next_line == '\n') next_line++; /* Skip lines that are quotes. */ @@ -412,6 +412,7 @@ gen_terms_part (Xapian::TermGenerator term_gen, GMimeStream *stream; GMimeDataWrapper *wrapper; GByteArray *byte_array; + GMimeContentDisposition *disposition; char *body; if (GMIME_IS_MULTIPART (part)) { @@ -438,6 +439,27 @@ gen_terms_part (Xapian::TermGenerator term_gen, 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)); + const char *extension; + + add_term (term_gen.get_document (), "label", "attachment"); + gen_terms (term_gen, "attachment", filename); + + if (filename) { + extension = strchr (filename, '.'); + if (extension) { + add_term (term_gen.get_document (), "attachment_extension", + extension + 1); + } + } + + return; + } + byte_array = g_byte_array_new (); stream = g_mime_stream_mem_new_with_byte_array (byte_array);