You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2015/10/21 13:13:27 UTC

[jira] [Commented] (OAK-2774) Invalid characters not escaped while fulltext query parsing

    [ https://issues.apache.org/jira/browse/OAK-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14966643#comment-14966643 ] 

Stefan Seifert commented on OAK-2774:
-------------------------------------

i hit this problem today as well, same happens if e.g. a {{"}} is contained in the fulltext query expression.

the question is if its appropriate to throw a RuntimeException if the lucene query parsing fails. this makes it hard catching such parsing errors in the calling code.

is it indented to support lucene query syntax features in the jcr:contains() expression? then a proper InvalidQueryException or simular should be thrown.
otherwise escaping as recommended in this ticket should to the job.

> Invalid characters not escaped while fulltext query parsing
> -----------------------------------------------------------
>
>                 Key: OAK-2774
>                 URL: https://issues.apache.org/jira/browse/OAK-2774
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: lucene
>    Affects Versions: 1.2
>            Reporter: Rishabh Maurya
>
> Invalid characters such as forward slash {{/}} should be escaped, as fulltext search on them results in below error - 
> {code}
> java.lang.RuntimeException: INVALID_SYNTAX_CANNOT_PARSE: Syntax Error, cannot parse /bar: Lexical error at line 1, column 5.  Encountered: <EOF> after : "/bar" 
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.tokenToQuery(LucenePropertyIndex.java:1042)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$2.visitTerm(LucenePropertyIndex.java:983)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$2.visit(LucenePropertyIndex.java:978)
> 	at org.apache.jackrabbit.oak.query.fulltext.FullTextTerm.accept(FullTextTerm.java:215)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.getFullTextQuery(LucenePropertyIndex.java:933)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.getLuceneRequest(LucenePropertyIndex.java:519)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.access$200(LucenePropertyIndex.java:160)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$1.loadDocs(LucenePropertyIndex.java:321)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$1.computeNext(LucenePropertyIndex.java:274)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$1.computeNext(LucenePropertyIndex.java:265)
> 	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
> 	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
> 	at org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex$LucenePathCursor$1.hasNext(LucenePropertyIndex.java:1138)
> ...
> {code}
> http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/QueryParserBase.html#escape(java.lang.String)
> should be used to escape such invalid characters.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)