soma0212 opened a new pull request, #16892:
URL: https://github.com/apache/lucene/pull/16892
### Description
`QueryParserUtil.escape` is the escaping helper for the flexible
`StandardQueryParser`, but its character set was copied from the classic parser
and misses four characters that `StandardSyntaxParser.jj` treats as syntax:
- `=` is accepted in place of `:` for field selection, so
`escape("secret=x")` still parses to `secret:x`
- `<`, `<=`, `>`, `>=` build open-ended ranges, so `"price:" +
escape("<10")` or `escape("price<10")` parses to `price:[* TO 10}`
- `@` is the min-should-match operator and causes a lexical error when it is
left unescaped
Applications that escape user text this way before handing it to the
flexible parser can therefore still get a different field or a range query
instead of a plain term. `EscapeQuerySyntaxImpl`, which the same parser uses
for `toQueryString`, already escapes all four, so only this helper was out of
sync. The classic `QueryParserBase.escape` is unaffected because the classic
grammar does not use these characters.
`TestQPHelper.testQueryStringEscaping` now checks the escaped output and
that parsing the escaped text gives a single `TermQuery` on the default field.
`./gradlew :lucene:queryparser:test` and `:lucene:queryparser:check` pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]