This is an automated email from the ASF dual-hosted git repository.
baedke pushed a commit to branch issue/oak-10611
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/issue/oak-10611 by this push:
new 1d0e596922 OAK-10611: o.a.j.o.namepath.JcrPathParser does not handle
invalid characters correctly
1d0e596922 is described below
commit 1d0e596922331dd059b31d0381c1794c883f2ee2
Author: Manfred Baedke <[email protected]>
AuthorDate: Tue Jan 23 14:10:40 2024 +0100
OAK-10611: o.a.j.o.namepath.JcrPathParser does not handle invalid
characters correctly
Fixed treatment of square brackets in some edge cases.
---
.../jackrabbit/oak/namepath/JcrPathParser.java | 25 +++++++++++-----------
.../jackrabbit/oak/namepath/PathParserTest.java | 8 +++----
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java
index 614c6d7a1d..0309d931a6 100644
---
a/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java
+++
b/oak-core-spi/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java
@@ -200,18 +200,6 @@ public final class JcrPathParser {
}
break;
- case '[':
- if (state == STATE_PREFIX || state == STATE_NAME) {
- if (wasSlash) {
- pathAwareListener.error("Trailing slashes not
allowed in prefixes and names.");
- return false;
- }
- state = STATE_INDEX;
- name = jcrPath.substring(lastPos, pos - 1);
- lastPos = pos;
- }
- break;
-
case ']':
if (state == STATE_INDEX) {
try {
@@ -254,6 +242,19 @@ public final class JcrPathParser {
}
break;
+ case '[':
+ if (state == STATE_PREFIX || state == STATE_NAME) {
+ if (wasSlash) {
+ pathAwareListener.error("Trailing slashes not
allowed in prefixes and names.");
+ return false;
+ }
+ state = STATE_INDEX;
+ name = jcrPath.substring(lastPos, pos - 1);
+ lastPos = pos;
+ break;
+ }
+ // intentionally no break, so we get the default treatment
for all other states
+
default:
if (state == STATE_PREFIX_START || state == STATE_DOT ||
state == STATE_DOTDOT) {
state = STATE_PREFIX;
diff --git
a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
index 739337bce3..e91e6a2b19 100755
---
a/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
+++
b/oak-core-spi/src/test/java/org/apache/jackrabbit/oak/namepath/PathParserTest.java
@@ -252,7 +252,6 @@ public class PathParserTest {
//TODO add more tests to cover all edge cases
@Test
- @Ignore //OAK-10611
public void testUnexpectedOpeningSquareBracket() throws
RepositoryException {
String path = "[";
TestListener listener = new TestListener(
@@ -301,20 +300,21 @@ public class PathParserTest {
path = "a[[";
listener = new TestListener(
+ CALLBACKRESULT_ERROR_ANY
//the parser actually produces an error, but we should change
the error message to something like this
- CALLBACKRESULT_ERROR(errorClosingQuareBracketExpected(path))
+ //CALLBACKRESULT_ERROR(errorClosingQuareBracketExpected(path))
);
verifyResult(path, listener, false);
}
@Test
- @Ignore //OAK-10611
public void testMissingClosingSquareBracket() throws RepositoryException {
String path = "/a[";
TestListener listener = new TestListener(
CALLBACKRESULT_ROOT,
+ CALLBACKRESULT_ERROR_ANY
//the parser actually produces an error, but we should change
the error message to something like this
- CALLBACKRESULT_ERROR(errorClosingQuareBracketExpected(path))
+ //CALLBACKRESULT_ERROR(errorClosingQuareBracketExpected(path))
);
verifyResult(path, listener, false);
}