You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2013/04/11 18:34:43 UTC

svn commit: r1466957 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java

Author: reschke
Date: Thu Apr 11 16:34:43 2013
New Revision: 1466957

URL: http://svn.apache.org/r1466957
Log:
JCR-3562: fix NameParser to accept "{a" as a valid local (non-expanded) name (ported to 2.4)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
    jackrabbit/branches/2.4/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1466938

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java?rev=1466957&r1=1466956&r2=1466957&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java Thu Apr 11 16:34:43 2013
@@ -397,4 +397,16 @@ public class NodeImplTest extends Abstra
         root.remove();
         session.save();
     }
+
+    public void testBracketsInNodeName() throws Exception {
+        final Node root = testRootNode.addNode("testBracketsInNodeName");
+
+        final String[] childNames = { "{A}", "B}", "{C", "(D)", "E)", "(F", };
+
+        for (String name : childNames) {
+            root.addNode(name);
+            root.getSession().save();
+            assertTrue("Expecting child " + name + " to have been created", root.hasNode(name));
+        }
+    }
 }

Modified: jackrabbit/branches/2.4/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java?rev=1466957&r1=1466956&r2=1466957&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java Thu Apr 11 16:34:43 2013
@@ -47,7 +47,7 @@ public class PathParser {
 
     /**
      * Parses <code>jcrPath</code> into a <code>Path</code> object using
-     * <code>resolver</code> to convert prefixes into namespace URI's. If
+     * <code>resolver</code> to convert prefixes into namespace URIs. If
      * resolver is <code>null</code> this method only checks the format of the
      * passed String and returns <code>null</code>.
      *
@@ -66,7 +66,7 @@ public class PathParser {
 
     /**
      * Parses <code>jcrPath</code> into a <code>Path</code> object using
-     * <code>resolver</code> to convert prefixes into namespace URI's. If the
+     * <code>resolver</code> to convert prefixes into namespace URIs. If the
      * specified <code>jcrPath</code> is an identifier based absolute path
      * beginning with an identifier segment the specified
      * <code>IdentifierResolver</code> will be used to resolve it to an
@@ -94,7 +94,7 @@ public class PathParser {
 
     /**
      * Parses <code>jcrPath</code> into a <code>Path</code> object using
-     * <code>resolver</code> to convert prefixes into namespace URI's. If the
+     * <code>resolver</code> to convert prefixes into namespace URIs. If the
      * specified <code>jcrPath</code> is an identifier based absolute path
      * beginning with an identifier segment the specified
      * <code>IdentifierResolver</code> will be used to resolve it to an
@@ -132,7 +132,7 @@ public class PathParser {
      * @param parent   the parent path
      * @param jcrPath  the JCR path
      * @param resolver the namespace resolver to get prefixes for namespace
-     *                 URI's.
+     *                 URIs.
      * @param factory
      * @return the <code>Path</code> object.
      * @throws MalformedPathException If the <code>jcrPath</code> is malformed.
@@ -262,6 +262,10 @@ public class PathParser {
                     if (state == STATE_PREFIX_START && c != EOF) {
                         throw new MalformedPathException("'" + jcrPath + "' is not a valid path. double slash '//' not allowed.");
                     }
+                    if (state == STATE_URI && c == EOF) {
+                        // this handles the case where URI state was entered but the end of the segment was reached (JCR-3562)
+                        state = STATE_URI_END;
+                    }
                     if (state == STATE_PREFIX
                             || state == STATE_NAME
                             || state == STATE_INDEX_END
@@ -289,7 +293,7 @@ public class PathParser {
                         index = Path.INDEX_UNDEFINED;
                     } else if (state == STATE_IDENTIFIER) {
                         if (c == EOF) {
-                            // eof identifier reached                            
+                            // eof identifier reached
                             if (jcrPath.charAt(pos - 2) != ']') {
                                 throw new MalformedPathException("'" + jcrPath + "' is not a valid path: Unterminated identifier segment.");
                             }
@@ -414,7 +418,7 @@ public class PathParser {
                         state = STATE_URI_END;
                     }
                     break;
-                
+
                 default:
                     if (state == STATE_PREFIX_START || state == STATE_DOT || state == STATE_DOTDOT) {
                         state = STATE_PREFIX;