From 30f93663b0b92cb2ee7b8892ae2e7a7133956bb6 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 18 Nov 2012 22:09:56 +0200 Subject: [PATCH] * lib: do some more escaping of body text --- guile/tests/test-mu-guile.scm | 4 ++-- lib/mu-store-write.cc | 15 +++++++++++++++ lib/tests/testdir2/bar/cur/mail2 | 5 +++-- mu/tests/test-mu-cmd.c | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/guile/tests/test-mu-guile.scm b/guile/tests/test-mu-guile.scm index d982286e..a0d82b2e 100755 --- a/guile/tests/test-mu-guile.scm +++ b/guile/tests/test-mu-guile.scm @@ -97,9 +97,9 @@ exec guile -e main -s $0 $@ (define (test-stats) "Test statistical functions." ;; average - (num-equal-or-exit (mu:average mu:size) 81709/12) + (num-equal-or-exit (mu:average mu:size) 40859/6) (num-equal-or-exit (floor (mu:stddev mu:size)) - (floor 13414.7101616927)) + (floor 13413.7101616927)) (num-equal-or-exit (mu:max mu:size) 46230) (num-equal-or-exit (mu:min mu:size) 111)) diff --git a/lib/mu-store-write.cc b/lib/mu-store-write.cc index 56e3e7ef..ece18192 100644 --- a/lib/mu-store-write.cc +++ b/lib/mu-store-write.cc @@ -459,6 +459,19 @@ add_terms_values_attach (Xapian::Document& doc, MuMsg *msg, (MuMsgPartForeachFunc)each_part, &pdata); } +/* escape the body -- for now, only replace '-' with '_' */ +static void +body_escape_in_place (char *body) +{ + while (*body) { + switch (*body) { + case '-': *body = '_'; + default: break; + } + ++body; + } +} + static void add_terms_values_body (Xapian::Document& doc, MuMsg *msg, @@ -482,6 +495,8 @@ add_terms_values_body (Xapian::Document& doc, MuMsg *msg, /* norm is allocated on strchunk, no need for freeing */ norm = mu_str_normalize (str, TRUE, strchunk); + body_escape_in_place (norm); + termgen.index_text_without_positions (norm, 1, prefix(mfid)); } diff --git a/lib/tests/testdir2/bar/cur/mail2 b/lib/tests/testdir2/bar/cur/mail2 index 5bb92087..3799f304 100644 --- a/lib/tests/testdir2/bar/cur/mail2 +++ b/lib/tests/testdir2/bar/cur/mail2 @@ -1,6 +1,6 @@ Date: Thu, 31 Jul 2008 14:57:25 -0400 From: "Socrates" -Subject: cool stuff +Subject: cool stuff To: "Alcibiades" Message-id: <3BE9E6535E0D852173@emss35m06.us.lmco.com> MIME-version: 1.0 @@ -9,5 +9,6 @@ Content-transfer-encoding: 7BIT Precedence: high The hour of departure has arrived, and we go our ways—I to die, and you to -live. Which is better God only knows. +live. Which is better God only knows. +http-emacs diff --git a/mu/tests/test-mu-cmd.c b/mu/tests/test-mu-cmd.c index 1626c400..67daa459 100644 --- a/mu/tests/test-mu-cmd.c +++ b/mu/tests/test-mu-cmd.c @@ -146,6 +146,7 @@ test_mu_find_01 (void) search ("f:soc@example.com", 1); search ("t:alki@example.com", 1); search ("t:alcibiades", 1); + search ("http-emacs", 1); search ("f:soc@example.com OR f:john", 2); search ("f:soc@example.com OR f:john OR t:edmond", 3); search ("t:julius", 1);