[jira] Commented: (JCR-1248) Helper Method to escape illegal XPath Search Term
[ https://issues.apache.org/jira/browse/JCR-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840071#action_12840071 ] Paco Avila commented on JCR-1248: - I'm not sure if is a bug or a "feature". The query String term = "pe[]pe"; String scapedTerm = Text.escapeIllegalXpathSearchChars(term).replaceAll("'", "''") String query = "/jcr:root//*[jcr:contains(okm:content,'"+escapedTerm+"')]" should fail or the term "pe[]pe" should be escaped as "pe\[\]pe"? > Helper Method to escape illegal XPath Search Term > - > > Key: JCR-1248 > URL: https://issues.apache.org/jira/browse/JCR-1248 > Project: Jackrabbit Content Repository > Issue Type: New Feature > Components: jackrabbit-jcr-commons >Reporter: Claus Köll >Assignee: Claus Köll >Priority: Minor > Fix For: 1.5.0 > > Attachments: patch.txt > > > If you try to perform a search like this > //element(*, nt:base)[jcr:contains(., 'test!')] > you get this exception > javax.jcr.RepositoryException: Exception building query: > org.apache.jackrabbit.core.query.lucene.fulltext.ParseException: Encountered > "" at line 1, column 6. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-1248) Helper Method to escape illegal XPath Search Term
[ https://issues.apache.org/jira/browse/JCR-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840068#action_12840068 ] Paco Avila commented on JCR-1248: - By the way, this sample code at http://wiki.apache.org/jackrabbit/EncodingAndEscaping is recursive: String q = "/jcr:root/foo/element(*, foo)" + "[jcr:contains(@title, '" + Text.escapeIllegalXpathSearchChars(q).replaceAll("'", "''") + "')]" + "[...@itemid = '" + itemID.replaceAll("'", "''") + "']"; > Helper Method to escape illegal XPath Search Term > - > > Key: JCR-1248 > URL: https://issues.apache.org/jira/browse/JCR-1248 > Project: Jackrabbit Content Repository > Issue Type: New Feature > Components: jackrabbit-jcr-commons >Reporter: Claus Köll >Assignee: Claus Köll >Priority: Minor > Fix For: 1.5.0 > > Attachments: patch.txt > > > If you try to perform a search like this > //element(*, nt:base)[jcr:contains(., 'test!')] > you get this exception > javax.jcr.RepositoryException: Exception building query: > org.apache.jackrabbit.core.query.lucene.fulltext.ParseException: Encountered > "" at line 1, column 6. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-1248) Helper Method to escape illegal XPath Search Term
[ https://issues.apache.org/jira/browse/JCR-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12839871#action_12839871 ] Alexander Klimetschek commented on JCR-1248: > A query like this will fail: > //element(*, nt:base)[jcr:contains(., 'test \ done')] Did you use org.apache.jackrabbit.util.Text.escapeIllegalXpathSearchChars() ? In case that one has a bug, please file a new issue. See also http://wiki.apache.org/jackrabbit/EncodingAndEscaping > Helper Method to escape illegal XPath Search Term > - > > Key: JCR-1248 > URL: https://issues.apache.org/jira/browse/JCR-1248 > Project: Jackrabbit Content Repository > Issue Type: New Feature > Components: jackrabbit-jcr-commons >Reporter: Claus Köll >Assignee: Claus Köll >Priority: Minor > Fix For: 1.5.0 > > Attachments: patch.txt > > > If you try to perform a search like this > //element(*, nt:base)[jcr:contains(., 'test!')] > you get this exception > javax.jcr.RepositoryException: Exception building query: > org.apache.jackrabbit.core.query.lucene.fulltext.ParseException: Encountered > "" at line 1, column 6. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (JCR-1248) Helper Method to escape illegal XPath Search Term
[ https://issues.apache.org/jira/browse/JCR-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12839819#action_12839819 ] Paco Avila commented on JCR-1248: - A query like this will fail: //element(*, nt:base)[jcr:contains(., 'test[')] Specification JSR-170 at point 6.6.5.2 says that literal instances like single quote ( ' ), double quote ( " ) and hyphen ( - ) must be escaped with a backslash ( \ ), and backslash itself should be escaped as a double backslash ( \\ ). Also, I have noted that some chars like [ and ] need to be escaped also. > Helper Method to escape illegal XPath Search Term > - > > Key: JCR-1248 > URL: https://issues.apache.org/jira/browse/JCR-1248 > Project: Jackrabbit Content Repository > Issue Type: New Feature > Components: jackrabbit-jcr-commons >Reporter: Claus Köll >Assignee: Claus Köll >Priority: Minor > Fix For: 1.5.0 > > Attachments: patch.txt > > > If you try to perform a search like this > //element(*, nt:base)[jcr:contains(., 'test!')] > you get this exception > javax.jcr.RepositoryException: Exception building query: > org.apache.jackrabbit.core.query.lucene.fulltext.ParseException: Encountered > "" at line 1, column 6. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.