Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with wildcard usage in paths containing names starting with digits #688

Closed
Vocinglero opened this issue Feb 27, 2024 · 6 comments · Fixed by #708
Closed

Issues with wildcard usage in paths containing names starting with digits #688

Vocinglero opened this issue Feb 27, 2024 · 6 comments · Fixed by #708
Assignees
Milestone

Comments

@Vocinglero
Copy link

Vocinglero commented Feb 27, 2024

Hello,

In our project, we have encountered an issue with folder names in our DAM that include numbers. When we specify ACL rules targeting a specific path directly, everything functions as expected. However, an error arises if we attempt to use a wildcard in the path specification.

For instance, consider the following rule:

- path: '/content/dam/brands/21c/global-marketing/*/'
   permission: allow
   privileges: jcr:read

This setup results in an error stating: "Could not process yaml files / e=javax.jcr.query.InvalidQueryException: java.text.ParseException: Query: /jcr:root/content/dam/brands/"21c"()/global-marketing/; expected: jcr:root, /, *, @, (, ."

It's important to note that if we use the path /content/dam/brands/21c/global-marketing without the wildcard, it operates correctly.

@kwin
Copy link
Member

kwin commented May 3, 2024

@Vocinglero Can you share a yaml which allows us to reproduce the error?

@Vocinglero
Copy link
Author

@kwin Here are the 2 yaml files we use
Archive.zip

@kwin
Copy link
Member

kwin commented May 5, 2024

@Vocinglero Thanks, I could reproduce. The full stack trace from the exception is as follows:

javax.jcr.query.InvalidQueryException: java.text.ParseException: Query:_/jcr:root/content/dam/brands/21(*)c/global-marketing/*; expected: jcr:root, /, *, @, (, .
	at org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl.executeQuery(QueryManagerImpl.java:149) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.jcr.query.QueryImpl$2.perform(QueryImpl.java:105) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.jcr.query.QueryImpl$2.perform(QueryImpl.java:101) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:229) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.jcr.query.QueryImpl.execute(QueryImpl.java:100) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	at biz.netcentric.cq.tools.actool.helper.QueryHelper.getNodesFromQuery(QueryHelper.java:154)
	at biz.netcentric.cq.tools.actool.helper.QueryHelper.getNodePathsFromQuery(QueryHelper.java:164)
	at biz.netcentric.cq.tools.actool.helper.QueryHelper.getNodePathsFromQuery(QueryHelper.java:132)
	at biz.netcentric.cq.tools.actool.configreader.YamlConfigReader.handleWildcards(YamlConfigReader.java:297)
	at biz.netcentric.cq.tools.actool.configreader.YamlConfigReader.getPreservedOrderdAceSet(YamlConfigReader.java:280)
	at biz.netcentric.cq.tools.actool.configreader.YamlConfigReader.getAceConfigurationBeans(YamlConfigReader.java:126)
	at biz.netcentric.cq.tools.actool.configreader.YamlConfigurationMerger.getMergedConfigurations(YamlConfigurationMerger.java:188)
	at biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl.installConfigurationFiles(AcInstallationServiceImpl.java:286)
	at biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl.apply(AcInstallationServiceImpl.java:217)
...
Caused by: java.text.ParseException: Query:_/jcr:root/content/dam/brands/21(*)c/global-marketing/*; expected: jcr:root, /, *, @, (, .
	at org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter.getSyntaxError(XPathToSQL2Converter.java:1222) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter.getSyntaxError(XPathToSQL2Converter.java:1212) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter.convertToStatement(XPathToSQL2Converter.java:364) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter.convert(XPathToSQL2Converter.java:99) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.query.QueryEngineImpl.parseQuery(QueryEngineImpl.java:194) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.query.QueryEngineImpl.executeQuery(QueryEngineImpl.java:267) [org.apache.jackrabbit.oak-core:1.60.0.T20240131102219-0cde853]
	at org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl.executeQuery(QueryManagerImpl.java:137) [org.apache.jackrabbit.oak-jcr:1.60.0.T20240131102219-0cde853]
	... 178 common frames omitted

@kwin
Copy link
Member

kwin commented May 5, 2024

The problem here is not the wildcard at the end, but the name 21c which is not a valid name in XML ( https://www.w3.org/TR/REC-xml/#NT-NameStartChar). It needs to be escaped according to the rules outlined in https://jackrabbit.apache.org/archive/wiki/JCR/EncodingAndEscaping_115513396.html#EncodingAndEscaping-Encodingpathinqueries.

@Vocinglero
Copy link
Author

Vocinglero commented May 5, 2024

@kwin thanks. I thought it was caused by the wildcard because this works fine: path: '/content/dam/brands/21c/global-marketing', while this does not path: '/content/dam/brands/21c/global-marketing/*/'

@kwin
Copy link
Member

kwin commented May 5, 2024

@Vocinglero Without wildcard there is no query involved, therefore you need the wildcard to trigger it.

@kwin kwin changed the title Issues with wildcard usage in paths with numbers Issues with wildcard usage in paths containing names starting with digits May 5, 2024
kwin added a commit that referenced this issue May 5, 2024
@kwin kwin added this to the 3.1.0 milestone May 5, 2024
@kwin kwin self-assigned this May 5, 2024
@kwin kwin closed this as completed in #708 May 7, 2024
kwin added a commit that referenced this issue May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants