ChlineSaurus commented on code in PR #3084:
URL: https://github.com/apache/jackrabbit-oak/pull/3084#discussion_r3820397275
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java:
##########
@@ -1006,6 +1007,9 @@ private void initialize(String query) throws
ParseException {
} else {
if (Character.isJavaIdentifierPart(c)) {
type = CHAR_NAME;
+ } else if ((settings == null ||
settings.isXmlNameCharsInPathEnabled()) && XMLChar.isName(c)) {
Review Comment:
There is one case I found, but I'm not sure how realistic it is. The query
so far interpreted XML characters as whitespaces. If this is in the middle, it
failed, as described in the Issue. However, if the XML character is directly
next to a separator, it is ignored, meaning the new behavior can change queries
behavior for such queries instead of failing (See test below for an example.)
Not sure the feature toggle is too defensive, but better safe than sorry.
```
@Test
public void testXmlNameCharsInPathFeatureChangesBehavior() throws
ParseException {
// a middle dot (\u00b7) attached to a name is dropped when the
feature is disabled,
// but kept as part of the name when enabled, resulting in a
different query
String xpath = "//*[@a\u00b7 = 1]";
QueryEngineSettings disabled = new QueryEngineSettings();
disabled.setXmlNameCharsInPathFeature(createFeature(false));
String withoutFeature = new
XPathToSQL2Converter(disabled).convert(xpath);
QueryEngineSettings enabled = new QueryEngineSettings();
enabled.setXmlNameCharsInPathFeature(createFeature(true));
String withFeature = new
XPathToSQL2Converter(enabled).convert(xpath);
assertTrue(withoutFeature.contains("[a] = 1"));
assertTrue(withFeature.contains("[a\u00b7] = 1"));
assertNotEquals(withoutFeature, withFeature);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]