[
https://issues.apache.org/jira/browse/LUCENE-6221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shaun A Elliott updated LUCENE-6221:
------------------------------------
Description:
The current QueryParser escape method does not escape whole word operators (OR,
AND, NOT):
{code}
public static String escape(String s) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// 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 == '/') {
sb.append('\\');
}
sb.append(c);
}
return sb.toString();
}
{code}
It would be better if these words were escaped too.
was:
The current QueryParser escape method does not escape whole word operators (OR,
AND, NOT):
{code}
public static String escape(String s) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// 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 == '/') {
sb.append('\\');
}
sb.append(c);
}
return sb.toString();
}
{code}
It would be better if these words were escaped too.
Summary: escape whole word operators (OR, AND, NOT) (was: escape
operators)
> escape whole word operators (OR, AND, NOT)
> ------------------------------------------
>
> Key: LUCENE-6221
> URL: https://issues.apache.org/jira/browse/LUCENE-6221
> Project: Lucene - Core
> Issue Type: Improvement
> Components: core/queryparser
> Reporter: Shaun A Elliott
>
> The current QueryParser escape method does not escape whole word operators
> (OR, AND, NOT):
> {code}
> public static String escape(String s) {
> StringBuilder sb = new StringBuilder();
> for (int i = 0; i < s.length(); i++) {
> char c = s.charAt(i);
> // 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 == '/') {
> sb.append('\\');
> }
> sb.append(c);
> }
> return sb.toString();
> }
> {code}
> It would be better if these words were escaped too.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]