From 1dda2bb5371360f7f7afda5481ff5374dd0e051c Mon Sep 17 00:00:00 2001 From: trinity-1686a Date: Fri, 27 Oct 2023 08:57:02 +0200 Subject: [PATCH] handle * inside term in query parser (#2228) --- query-grammar/src/query_grammar.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/query-grammar/src/query_grammar.rs b/query-grammar/src/query_grammar.rs index 81d939ca9..ed3dd1fdb 100644 --- a/query-grammar/src/query_grammar.rs +++ b/query-grammar/src/query_grammar.rs @@ -185,7 +185,7 @@ fn term_or_phrase(inp: &str) -> IResult<&str, UserInputLeaf> { fn term_or_phrase_infallible(inp: &str) -> JResult<&str, Option> { map( // ~* for slop/prefix, ) inside group or ast tree, ^ if boost - tuple_infallible((simple_term_infallible("*)^"), slop_or_prefix_val)), + tuple_infallible((simple_term_infallible(")^"), slop_or_prefix_val)), |((delimiter_phrase, (slop, prefix)), errors)| { let leaf = if let Some((delimiter, phrase)) = delimiter_phrase { Some( @@ -1113,6 +1113,9 @@ mod test { test_parse_query_to_ast_helper("'www-form-encoded'", "'www-form-encoded'"); test_parse_query_to_ast_helper("www-form-encoded", "www-form-encoded"); test_parse_query_to_ast_helper("www-form-encoded", "www-form-encoded"); + test_parse_query_to_ast_helper("mr james bo?d", "(*mr *james *bo?d)"); + test_parse_query_to_ast_helper("mr james bo*", "(*mr *james *bo*)"); + test_parse_query_to_ast_helper("mr james b*d", "(*mr *james *b*d)"); } #[test]