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

Benjamin Papez edited comment on JCR-2732 at 4/6/11 8:01 AM:
-------------------------------------------------------------

I submitted a patch to fix the exception. The problem in the code is that in 
case of '~' and ':' the escaped flag is not propertly handled. So if the 
predecesessor of these two characters is the escaping backslash setting escaped 
to true, the successor character after '~' or ':' will be escaped, which is not 
intended.

      was (Author: bpapez):
    Index: JackrabbitQueryParser.java
===================================================================
--- JackrabbitQueryParser.java  (revision 1089329)
+++ JackrabbitQueryParser.java  (working copy)
@@ -87,10 +87,17 @@
                     // escape tilde so we can use it for similarity query
                     rewritten.append("\\");
                 }
+                if (escaped) {
+                    rewritten.append('\\');
+                    escaped = false;
+                }                              
                 rewritten.append('~');
             } else if (textsearch.charAt(i) == ':') {
                 // fields as known in lucene are not supported
                 rewritten.append("\\:");
+                if (escaped) {
+                    escaped = false;
+                }                              
             } else {
                 if (escaped) {
                     rewritten.append('\\');

  
> ParseException in xpath query using an escaped string in jackrabbit 2.x 
> (works in 1.6)
> --------------------------------------------------------------------------------------
>
>                 Key: JCR-2732
>                 URL: https://issues.apache.org/jira/browse/JCR-2732
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: query, xpath
>    Affects Versions: 2.2.4
>            Reporter: fabrizio giustina
>         Attachments: ColonBracketSearchTest.java, JackrabbitQueryParser.patch
>
>
> For a particular sequence of chars, ":)" os ":(", jackrabbit 2.x seems to 
> break also when the xpath statement is properly escaped
> Looks like the way I escape the ":)" os ":(" sequence was used to work fine 
> in jackrabbit 1.6, but produces a parsing error in jackrabbit 2.x.
> The following query, with a space in between ":" and ")" works fine in any 
> version of jackrabbit:
> {code}
> //*[jcr:contains(@title, '\: \)')]
> {code}
> This one, without any space, works only in jackrabbit 1.6:
> {code}
> //*[jcr:contains(@title, '\:\)')]
> {code}
> in 2.x the result is a ParseException: Cannot parse '\:\\)': Encountered " 
> ")" ")
> Is anything changed in how xpath queries must be escaped in 2.x or Is this a 
> bug?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to