mirror of https://github.com/apache/lucene.git
LUCENE-881: QueryParser.escape() now also escapes the characters '|' and '&'
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@540839 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b1eb460b7e
commit
45f760ea24
|
@ -128,6 +128,9 @@ Bug fixes
|
|||
16. LUCENE-883: consecutive calls to Spellchecker.indexDictionary()
|
||||
won't insert terms twice anymore. (Daniel Naber)
|
||||
|
||||
17. LUCENE-881: QueryParser.escape() now also escapes the characters
|
||||
'|' and '&' which are part of the queryparser syntax. (Michael Busch)
|
||||
|
||||
New features
|
||||
|
||||
1. LUCENE-759: Added two n-gram-producing TokenFilters.
|
||||
|
|
|
@ -803,7 +803,7 @@ public class QueryParser implements QueryParserConstants {
|
|||
// These characters are part of the query syntax and must be escaped
|
||||
if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':'
|
||||
|| c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~'
|
||||
|| c == '*' || c == '?') {
|
||||
|| c == '*' || c == '?' || c == '|' || c == '&') {
|
||||
sb.append('\\');
|
||||
}
|
||||
sb.append(c);
|
||||
|
|
|
@ -827,7 +827,7 @@ public class QueryParser {
|
|||
// These characters are part of the query syntax and must be escaped
|
||||
if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':'
|
||||
|| c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~'
|
||||
|| c == '*' || c == '?') {
|
||||
|| c == '*' || c == '?' || c == '|' || c == '&') {
|
||||
sb.append('\\');
|
||||
}
|
||||
sb.append(c);
|
||||
|
|
|
@ -616,6 +616,10 @@ public class TestQueryParser extends TestCase {
|
|||
assertEscapedQueryEquals("[ a - TO a+ ]", null, "\\[ a \\- TO a\\+ \\]");
|
||||
assertEscapedQueryEquals("[ a : TO a~ ]", null, "\\[ a \\: TO a\\~ \\]");
|
||||
assertEscapedQueryEquals("[ a\\ TO a* ]", null, "\\[ a\\\\ TO a\\* \\]");
|
||||
|
||||
// LUCENE-881
|
||||
assertEscapedQueryEquals("|| abc ||", a, "\\|\\| abc \\|\\|");
|
||||
assertEscapedQueryEquals("&& abc &&", a, "\\&\\& abc \\&\\&");
|
||||
}
|
||||
|
||||
public void testTabNewlineCarriageReturn()
|
||||
|
|
Loading…
Reference in New Issue