* support special characters in X-Labels
This commit is contained in:
@ -212,7 +212,7 @@ static const MuMsgField FIELD_DATA[] = {
|
|||||||
MU_MSG_FIELD_TYPE_STRING_LIST,
|
MU_MSG_FIELD_TYPE_STRING_LIST,
|
||||||
"tag", 'x', 'X',
|
"tag", 'x', 'X',
|
||||||
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_PREFIX_ONLY |
|
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_PREFIX_ONLY |
|
||||||
FLAG_NORMALIZE
|
FLAG_NORMALIZE | FLAG_XAPIAN_ESCAPE
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -408,6 +408,9 @@ add_terms_values_string_list (Xapian::Document& doc, MuMsg *msg,
|
|||||||
if (mu_msg_field_normalize (mfid))
|
if (mu_msg_field_normalize (mfid))
|
||||||
mu_str_normalize_in_place (val, TRUE);
|
mu_str_normalize_in_place (val, TRUE);
|
||||||
|
|
||||||
|
if (mu_msg_field_xapian_escape (mfid))
|
||||||
|
mu_str_ascii_xapian_escape_in_place (val);
|
||||||
|
|
||||||
doc.add_term (prefix(mfid) +
|
doc.add_term (prefix(mfid) +
|
||||||
std::string(val, 0, MU_STORE_MAX_TERM_LENGTH));
|
std::string(val, 0, MU_STORE_MAX_TERM_LENGTH));
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,6 @@ run_and_count_matches (const char *xpath, const char *query)
|
|||||||
MuQuery *mquery;
|
MuQuery *mquery;
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
guint count1, count2;
|
guint count1, count2;
|
||||||
GHashTable *hash;
|
|
||||||
|
|
||||||
mquery = mu_query_new (xpath, NULL);
|
mquery = mu_query_new (xpath, NULL);
|
||||||
g_assert (query);
|
g_assert (query);
|
||||||
@ -107,9 +106,6 @@ run_and_count_matches (const char *xpath, const char *query)
|
|||||||
mu_query_destroy (mquery);
|
mu_query_destroy (mquery);
|
||||||
g_assert (iter);
|
g_assert (iter);
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
||||||
(GDestroyNotify)g_free, NULL);
|
|
||||||
|
|
||||||
assert_no_dups (iter);
|
assert_no_dups (iter);
|
||||||
|
|
||||||
/* run query twice, to test mu_msg_iter_reset */
|
/* run query twice, to test mu_msg_iter_reset */
|
||||||
@ -450,6 +446,36 @@ test_mu_query_tags (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_query_tags_02 (void)
|
||||||
|
{
|
||||||
|
gchar *xpath;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
QResults queries[] = {
|
||||||
|
{ "x:paradise", 1},
|
||||||
|
{ "tag:@NextActions", 1},
|
||||||
|
{ "x:queensrÿche", 1},
|
||||||
|
{ "tag:lost OR tag:operation:mindcrime", 2},
|
||||||
|
};
|
||||||
|
|
||||||
|
xpath = fill_database (MU_TESTMAILDIR2);
|
||||||
|
g_assert (xpath != NULL);
|
||||||
|
|
||||||
|
/* g_print ("(%s)\n", xpath); */
|
||||||
|
|
||||||
|
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||||
|
/* g_print ("%s\n", queries[i].query); */
|
||||||
|
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||||
|
==, queries[i].count);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (xpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -474,6 +500,8 @@ main (int argc, char *argv[])
|
|||||||
test_mu_query_attach);
|
test_mu_query_attach);
|
||||||
g_test_add_func ("/mu-query/test-mu-query-tags",
|
g_test_add_func ("/mu-query/test-mu-query-tags",
|
||||||
test_mu_query_tags);
|
test_mu_query_tags);
|
||||||
|
g_test_add_func ("/mu-query/test-mu-query-tags_02",
|
||||||
|
test_mu_query_tags_02);
|
||||||
|
|
||||||
g_log_set_handler (NULL,
|
g_log_set_handler (NULL,
|
||||||
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||||
|
|||||||
Reference in New Issue
Block a user