From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [rfc patch 6/6] lib/index: add simple html filter
Date: Tue, 21 Mar 2017 10:15:49 -0300 [thread overview]
Message-ID: <20170321131549.19557-7-david@tethera.net> (raw)
In-Reply-To: <20170321131549.19557-1-david@tethera.net>
Just drop all tags
---
lib/index.cc | 17 ++++++++++++++++-
test/T680-html-indexing.sh | 1 -
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/lib/index.cc b/lib/index.cc
index 3bb1ac1c..03223f7d 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -204,6 +204,18 @@ filter_filter_uuencode (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, si
}
static void
+filter_filter_html (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, size_t prespace,
+ char **outbuf, size_t *outlen, size_t *outprespace)
+{
+ static const scanner_state_t states[] = {
+ {0, '<', '<', 1, 0},
+ {1, '>', '>', 0, 1},
+ };
+ do_filter(states, 1,
+ gmime_filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
+}
+
+static void
filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
char **outbuf, size_t *outlen, size_t *outprespace)
{
@@ -250,7 +262,10 @@ notmuch_filter_discard_non_terms_new (GMimeContentType *content_type)
filter = (NotmuchFilterDiscardNonTerms *) g_object_newv (type, 0, NULL);
filter->state = 0;
filter->content_type = content_type;
- filter->real_filter = filter_filter_uuencode;
+ if (g_mime_content_type_is_type (content_type, "text", "html"))
+ filter->real_filter = filter_filter_html;
+ else
+ filter->real_filter = filter_filter_uuencode;
return (GMimeFilter *) filter;
}
diff --git a/test/T680-html-indexing.sh b/test/T680-html-indexing.sh
index 78768c4f..ee69209c 100755
--- a/test/T680-html-indexing.sh
+++ b/test/T680-html-indexing.sh
@@ -5,7 +5,6 @@ test_description="indexing of html parts"
add_email_corpus html
test_begin_subtest 'embedded images should not be indexed'
-test_subtest_known_broken
notmuch search kwpza7svrgjzqwi8fhb2msggwtxtwgqcxp4wbqr4wjddstqmeqa7 > OUTPUT
test_expect_equal_file /dev/null OUTPUT
--
2.11.0
prev parent reply other threads:[~2017-03-21 13:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 13:15 RFC: drop html tags David Bremner
2017-03-21 13:15 ` [rfc patch 1/6] test: add known broken test for indexing html David Bremner
2017-03-21 13:15 ` [rfc patch 2/6] lib: add content type argument to uuencode filter David Bremner
2017-03-21 13:15 ` [rfc patch 3/6] lib/index: Add another layer of indirection in filtering David Bremner
2017-03-21 13:15 ` [rfc patch 4/6] lib/index: separate state table definition from scanner David Bremner
2017-03-21 13:15 ` [rfc patch 5/6] lib/index: generalize filter name David Bremner
2017-03-21 13:15 ` David Bremner [this message]
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=20170321131549.19557-7-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/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).