* lib: do some more escaping of body text

This commit is contained in:
djcb 2012-11-18 22:09:56 +02:00
parent ef1791ec7c
commit 30f93663b0
4 changed files with 21 additions and 4 deletions

View File

@ -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))

View File

@ -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));
}

View File

@ -11,3 +11,4 @@ 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.
http-emacs

View File

@ -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);