Treat unbalanced quotes as no quotes; fix #7128

This commit is contained in:
Charles Lindsay 2013-09-19 14:29:59 -07:00
parent 5b3084b8b4
commit b7bfe388fa

View file

@ -631,7 +631,17 @@ private class Geary.ImapDB.Account : BaseObject {
// We ignore everything inside quotes to give the user a way to
// override our algorithm here. The idea is to offer one search query
// syntax for Geary that we can use locally and via IMAP, etc.
string[] words = raw_query.split_set(" \t\r\n:()%*\\");
string quote_balanced = raw_query;
if (Geary.String.count_char(raw_query, '"') % 2 != 0) {
// Remove the last quote if it's not balanced. This has the
// benefit of showing decent results as you type a quoted phrase.
int last_quote = raw_query.last_index_of_char('"');
assert(last_quote >= 0);
quote_balanced = raw_query.splice(last_quote, last_quote + 1, " ");
}
string[] words = quote_balanced.split_set(" \t\r\n:()%*\\");
bool in_quote = false;
StringBuilder prepared_query = new StringBuilder();
foreach (string s in words) {
@ -665,10 +675,9 @@ private class Geary.ImapDB.Account : BaseObject {
prepared_query.append(" ");
}
string prepared = prepared_query.str.strip();
if (in_quote)
prepared += "\"";
return prepared;
assert(!in_quote);
return prepared_query.str.strip();
}
// Append each id in the collection to the StringBuilder, in a format