Repository: lucy Updated Branches: refs/heads/0.6 779c0f628 -> a1c773bae
Fix handling of trailing double quotes in QueryParser Fixes LUCY-325. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/9e2b55a0 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/9e2b55a0 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/9e2b55a0 Branch: refs/heads/0.6 Commit: 9e2b55a04292a843ff7e408d905cdde4750360c7 Parents: 779c0f6 Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Sat May 20 16:01:30 2017 +0200 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Thu Feb 8 16:13:34 2018 +0100 ---------------------------------------------------------------------- core/Lucy/Search/QueryParser.c | 5 +++++ test/Lucy/Test/Search/TestQueryParserSyntax.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/9e2b55a0/core/Lucy/Search/QueryParser.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Search/QueryParser.c b/core/Lucy/Search/QueryParser.c index f17e131..569bd75 100644 --- a/core/Lucy/Search/QueryParser.c +++ b/core/Lucy/Search/QueryParser.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. http://git-wip-us.apache.org/repos/asf/lucy/blob/9e2b55a0/test/Lucy/Test/Search/TestQueryParserSyntax.c ---------------------------------------------------------------------- diff --git a/test/Lucy/Test/Search/TestQueryParserSyntax.c b/test/Lucy/Test/Search/TestQueryParserSyntax.c index 1cc4680..f3d8755 100644 --- a/test/Lucy/Test/Search/TestQueryParserSyntax.c +++ b/test/Lucy/Test/Search/TestQueryParserSyntax.c @@ -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); }