apache / apache/lucene

StringIndexOutOfBoundsException in parser/EscapeQuerySyntaxImpl.java [LUCENE-8572]

Open
#9,618 6 comments 0 reactions 0 assignees View on GitHub
affects-version:6.3 legacy-jira-priority:Major module:core/queryparser type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

With "lucene-queryparser-6.3.0", specifically in
"org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java"
 
when escaping strings containing extended unicode chars, and with a locale distinct from that of the character set the string uses, the process fails, with a "java.lang.StringIndexOutOfBoundsException".
 
The reason is that the comparison is done by previously converting all of the characters of the string to lower case chars, and by doing this, the original string size isn't anymore the same, but less, as of the transformed one, so that executing
 
org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java:89

fails with a java.lang.StringIndexOutOfBoundsException.

I wonder whether the transformation to lower case is really needed when treating the escape chars, since by avoiding it, the error may be avoided.

---
Migrated from [LUCENE-8572](https://issues.apache.org/jira/browse/LUCENE-8572) by Octavian Mocanu (@tonicava), updated Aug 10 2019

Contributor guide

Open the contributing guide

Research direction

Start with org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java, especially line 89, and reproduce the failure using lucene-queryparser-6.3.0 with extended Unicode characters under a differing locale. Trace the lower-case transformation and verify that escaping such strings no longer raises StringIndexOutOfBoundsException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.