Permalink
Browse files

Fix handling of trailing double quotes in QueryParser

Fixes LUCY-325.
  • Loading branch information...
1 parent b227941 commit 598b4d074029998d30ad9a3b85190cc95aa00e0a @nwellnhof nwellnhof committed May 20, 2017
Showing with 15 additions and 1 deletion.
  1. +5 −0 core/Lucy/Search/QueryParser.c
  2. +10 −1 test/Lucy/Test/Search/TestQueryParserSyntax.c
@@ -885,6 +885,11 @@ QParser_Expand_Leaf_IMP(QueryParser *self, Query *query) {
StrIter_Recede(tail, 1);
}
}
+ if (StrIter_Compare_To(top, (Obj*)tail) > 0) {
+ DECREF(tail);
+ DECREF(top);
+ return NULL;
+ }
String *source_text = StrIter_crop(top, tail);
// Either use LeafQuery's field or default to Parser's list.
@@ -334,6 +334,14 @@ syntax_test_double_colon() {
return TestQP_new("PHP::Interpreter", tree, NULL, 0);
}
+static TestQueryParser*
+syntax_test_trailing_quote() {
+ Query *mies = make_leaf_query(NULL, "mies");
+ Query *quote = make_leaf_query(NULL, "\" ");
+ Query *tree = make_poly_query(BOOLOP_OR, mies, quote, NULL);
+ return TestQP_new("mies\" ", tree, NULL, 0);
+}
+
/***************************************************************************/
typedef TestQueryParser*
@@ -371,6 +379,7 @@ static LUCY_TestQPSyntax_Test_t syntax_test_funcs[] = {
syntax_test_escaped_quotes_inside,
syntax_test_identifier_field_name,
syntax_test_double_colon,
+ syntax_test_trailing_quote,
NULL
};
@@ -445,7 +454,7 @@ test_query_parser_syntax(TestBatchRunner *runner) {
void
TestQPSyntax_Run_IMP(TestQueryParserSyntax *self, TestBatchRunner *runner) {
- TestBatchRunner_Plan(runner, (TestBatch*)self, 68);
+ TestBatchRunner_Plan(runner, (TestBatch*)self, 70);
test_query_parser_syntax(runner);
}

0 comments on commit 598b4d0

Please sign in to comment.