[ https://issues.apache.org/jira/browse/LUCENE-800?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doron Cohen updated LUCENE-800: ------------------------------- Attachment: Lucene-800-more-tests.patch Hi Michael, I reviewed this fix and it looks good and correct. All tests are passing, including the new ones. (well, a few backwards compatibility tests fail - I would check that later - but it is unrelated to this fix). While reviewing I added a few test cases just to make sure - attached Lucene-800-more-tests.patch in case you find that worthy to add. Regards, Doron > Incorrect parsing by QueryParser.parse() when it encounters backslashes > (always eats one backslash.) > ---------------------------------------------------------------------------------------------------- > > Key: LUCENE-800 > URL: https://issues.apache.org/jira/browse/LUCENE-800 > Project: Lucene - Java > Issue Type: Bug > Components: QueryParser > Reporter: Dilip Nimkar > Assigned To: Michael Busch > Priority: Minor > Attachments: Lucene-800-more-tests.patch, Lucene-800.patch > > > Test code and output follow. Tested Lucene 1.9 version only. Affects hose > who would index/search for Lucene's reserved characters. > Description: When an input search string has a sequence of N (java-escaped) > backslashes, where N >= 2, the QueryParser will produce a query in which that > sequence has N-1 backslashes. > TEST CODE: > Analyzer analyzer = new WhitespaceAnalyzer(); > String[] queryStrs = {"item:\\\\", > "item:\\\\*", > "(item:\\\\ item:ABCD\\\\))", > "(item:\\\\ item:ABCD\\\\)"}; > for (String queryStr : queryStrs) { > System.out.println("--------------------------------------"); > System.out.println("String queryStr = " + queryStr); > Query luceneQuery = null; > try { > luceneQuery = new QueryParser("_default_", analyzer).parse(queryStr); > System.out.println("luceneQuery.toString() = " + > luceneQuery.toString()); > } catch (Exception e) { > System.out.println(e.getClass().toString()); > } > } > OUTPUT (with remarks in comment notation:) > -------------------------------------- > String queryStr = item:\\ > luceneQuery.toString() = item:\ //One backslash has disappeared. > Searcher will fail on this query. > -------------------------------------- > String queryStr = item:\\* > luceneQuery.toString() = item:\* //One backslash has disappeared. > This query will search for something unintended. > -------------------------------------- > String queryStr = (item:\\ item:ABCD\\)) > luceneQuery.toString() = item:\ item:ABCD\) //This should have thrown a > ParseException because of an unescaped ')'. It did not. > -------------------------------------- > String queryStr = (item:\\ item:ABCD\\) > class org.apache.lucene.queryParser.ParseException //...and this one > should not have, but it did. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]