Re: v3 of drop HTML tags when indexing

2017-07-01 Thread David Bremner
David Bremner  writes:

> this obsoletes id:20170510113910.28444-1-da...@tethera.net
>
> This is a simplification of the previous version, rather than swapping
> function pointers, we swap scanner tables. Unforunately because of the
> reorganization, the interdiff is unhelpfully large.
>
> The series shrunk from 6 to 4 patches; that's partly a cheat as the
> old 2/6 is now part of 4/4.

Pushed this series to master

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


v3 of drop HTML tags when indexing

2017-06-07 Thread David Bremner
this obsoletes id:20170510113910.28444-1-da...@tethera.net

This is a simplification of the previous version, rather than swapping
function pointers, we swap scanner tables. Unforunately because of the
reorganization, the interdiff is unhelpfully large.

The series shrunk from 6 to 4 patches; that's partly a cheat as the
old 2/6 is now part of 4/4.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


v2 of drop HTML tags when indexing

2017-05-13 Thread David Bremner
This obsoletes id:20170322112306.12060-1-da...@tethera.net

Compared to the previous version:

- drop test already pushed upstream

- add diagram of new state machine

- add longer, and hopefully more illuminating comment about how the
  (new) state machines are encoded

- don't create the variable 'current', stick with the existing 'next'
  as a state index/pointer
  
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Drop HTML tags when indexing

2017-03-25 Thread David Bremner
David Bremner  writes:

> Steven Allen pointed out [2] that the previous scanner [1] was a
> little too simplistic. This version handles (or claims to) quoted
> strings in attributes, which can apparently contain '>'and '<'
> characters. This required generalizing the state machine runner a bit
> [3] to handle states with out-degree more than two.

For what it is worth, this series shrunk my index by about the same
amount as skipping html messages entirely: I have about 15% messages
with html parts, and this series made the index about 15% smaller.

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


Re: Drop HTML tags when indexing

2017-03-22 Thread Daniel Lublin (quite)
This patch is good. notmuch now gets through my whole archive of 175k mails,
memory usage peaking at 430M.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Drop HTML tags when indexing

2017-03-22 Thread David Bremner
Steven Allen pointed out [2] that the previous scanner [1] was a
little too simplistic. This version handles (or claims to) quoted
strings in attributes, which can apparently contain '>'and '<'
characters. This required generalizing the state machine runner a bit
[3] to handle states with out-degree more than two.


[1]: id:20170321131549.19557-1-da...@tethera.net
[2]: id:87wpbipl9z@tesseract.cs.unb.ca
[3]:
diff --git a/lib/index.cc b/lib/index.cc
index 03223f7d..324e6e79 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -122,23 +122,25 @@ do_filter (const scanner_state_t states[],
 register const char *inptr = inbuf;
 const char *inend = inbuf + inlen;
 char *outptr;
-int next;
+int next, current;
 (void) prespace;
 
 
 g_mime_filter_set_size (gmime_filter, inlen, FALSE);
 outptr = gmime_filter->outbuf;
 
+current = filter->state;
 while (inptr < inend) {
-   if (*inptr >= states[filter->state].a &&
-   *inptr <= states[filter->state].b)
-   {
-   next = states[filter->state].next_if_match;
-   }
-   else
-   {
-   next = states[filter->state].next_if_not_match;
-   }
+   /* do "fake transitions" until we fire a rule, or run out of rules */
+   do {
+   if (*inptr >= states[current].a && *inptr <= states[current].b)  {
+   next = states[current].next_if_match;
+   } else  {
+   next = states[current].next_if_not_match;
+   }
+
+   current = next;
+   } while (next != states[next].state);
 
if (filter->state < first_skipping_state)
*outptr++ = *inptr;
@@ -209,7 +211,11 @@ filter_filter_html (GMimeFilter *gmime_filter, char 
*inbuf, size_t inlen, size_t
 {
 static const scanner_state_t states[] = {
{0,  '<',  '<',  1,  0},
+   {1,  '\'', '\'', 4,  2},  /* scanning for quote or > */
+   {1,  '"',  '"',  5,  3},
{1,  '>',  '>',  0,  1},
+   {4,  '\'', '\'', 1,  4},  /* inside single quotes */
+   {5,  '"', '"',   1,  5},  /* inside double quotes */
 };
 do_filter(states, 1,
  gmime_filter, inbuf, inlen, prespace, outbuf, outlen, 
outprespace);
diff --git a/test/T680-html-indexing.sh b/test/T680-html-indexing.sh
index ee69209c..74f33708 100755
--- a/test/T680-html-indexing.sh
+++ b/test/T680-html-indexing.sh
@@ -8,4 +8,15 @@ test_begin_subtest 'embedded images should not be indexed'
 notmuch search kwpza7svrgjzqwi8fhb2msggwtxtwgqcxp4wbqr4wjddstqmeqa7 > OUTPUT
 test_expect_equal_file /dev/null OUTPUT
 
+test_begin_subtest 'ignore > in attribute text'
+notmuch search swordfish | notmuch_search_sanitize > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest 'non tag text should be indexed'
+notmuch search hunter2 | notmuch_search_sanitize > OUTPUT
+cat < EXPECTED
+thread:XXX   2009-11-17 [1/1] David Bremner; test html attachment (inbox 
unread)
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
diff --git a/test/corpora/html/attribute-text b/test/corpora/html/attribute-text
new file mode 100644
index ..6dae8194
--- /dev/null
+++ b/test/corpora/html/attribute-text
@@ -0,0 +1,15 @@
+From: David Bremner 
+To: David Bremner 
+Subject: test html attachment
+Date: Tue, 17 Nov 2009 21:28:38 +0600
+Message-ID: <87d1dajhgf@example.net>
+MIME-Version: 1.0
+Content-Type: text/html
+Content-Disposition: inline; filename=test.html
+
+
+  
+
+  
+  hunter2
+

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