* mu-str: treat '..' in non-range fields differently

This commit is contained in:
djcb 2013-06-01 06:07:29 -07:00
parent 60f75eea42
commit d57b109557
2 changed files with 13 additions and 6 deletions

View File

@ -463,7 +463,7 @@ check_for_field (const char *str, gboolean *is_field,
static gboolean
handle_esc_maybe (GString *gstr, char **cur, gunichar uc,
gboolean query_esc)
gboolean query_esc, gboolean range_field)
{
char kar;
@ -480,6 +480,9 @@ handle_esc_maybe (GString *gstr, char **cur, gunichar uc,
g_string_append_c (gstr, kar);
return TRUE;
case '.':
if (!range_field)
break;
if ((*cur)[1] == '.' && (*cur)[2] != '.') {
g_string_append (gstr, "..");
*cur = g_utf8_next_char (*cur);
@ -503,6 +506,7 @@ process_str (const char *str, gboolean xapian_esc, gboolean query_esc)
{
GString *gstr;
char *norm, *cur;
gboolean is_field, is_range_field;
norm = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
if (G_UNLIKELY(!norm)) { /* not valid utf8? */
@ -515,6 +519,8 @@ process_str (const char *str, gboolean xapian_esc, gboolean query_esc)
if (!norm)
return NULL;
check_for_field (str, &is_field, &is_range_field);
gstr = g_string_sized_new (strlen (norm));
for (cur = norm; cur && *cur; cur = g_utf8_next_char (cur)) {
@ -524,7 +530,8 @@ process_str (const char *str, gboolean xapian_esc, gboolean query_esc)
uc = g_utf8_get_char (cur);
if (xapian_esc)
if (handle_esc_maybe (gstr, &cur, uc, query_esc))
if (handle_esc_maybe (gstr, &cur, uc, query_esc,
is_range_field))
continue;
if (g_unichar_ismark(uc))

View File

@ -195,7 +195,7 @@ test_mu_str_process_query_term (void)
const char* esc;
} words [] = {
{ "aap@noot.mies", "aap_noot_mies" },
{ "Foo..Bar", "foo..bar" },
{ "Foo..Bar", "foo__bar" },
{ "Foo.Bar", "foo_bar" },
{ "Foo Bar", "foo_bar" },
{ "\\foo", "_foo" },
@ -205,9 +205,9 @@ test_mu_str_process_query_term (void)
{ "date:2010..2012", "date:2010..2012"},
{ "d:2010..2012", "d:2010..2012"},
{ "size:10..20", "size:10..20"},
{ "x:2010..2012", "x:2010..2012"},
{ "q:2010..2012", "q:2010..2012"},
{ "subject:2010..2012", "subject:2010..2012"},
{ "x:2010..2012", "x:2010__2012"},
{ "q:2010..2012", "q:2010__2012"},
{ "subject:2010..2012", "subject:2010__2012"},
{ "(maildir:foo)", "(maildir:foo)"},
{ "Тесла, Никола", "тесла__никола"},
{ "Masha@Аркона.ru", "masha_аркона_ru" },