Index: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java	(revision 1582265)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/NamePathMapperImpl.java	(revision )
@@ -238,11 +238,16 @@
         int slash = -1; // index of the last slash in the path
         int colon = -1; // index of the last colon in the path
 
-        switch (path.charAt(0)) {
+        char c0 = path.charAt(0);
+        if (Character.isWhitespace(c0)) {
+            return true;
+        }
+        switch (c0) {
             case '{': // possibly an expanded name
             case '[': // starts with an identifier
             case '.': // possibly "." or ".."
             case ':': // colon as the first character
+            case ' ': // space at start
                 return true;
             case '/':
                 if (length == 1) {
@@ -253,7 +258,11 @@
         }
 
         for (int i = 1; i < length; i++) {
-            switch (path.charAt(i)) {
+            char c = path.charAt(i);
+            if (Character.isWhitespace(c)) {
+                return true;
+            }
+            switch (c) {
                 case '{': // possibly an expanded name
                 case '[': // possibly an index
                 case ']': // illegal character if not part of index
@@ -282,6 +291,10 @@
                     }
                     slash = i;
                     break;
+                case ' ':
+                    if (i == length-1) {
+                        return true; // trailing space
+                    }
             }
         }
 
Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java	(revision 1582265)
+++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java	(revision )
@@ -360,7 +360,13 @@
                 "/jcr:con*ent",
                 "/con*ent",
                 "/jcr:con|ent",
-                "/con|ent");
+                "/con|ent",
+                "/content ",
+                "/ content",
+                "/content\t",
+                "/\tcontent",
+                "/jcr:con\tent",
+                "con\tent");
         for (String path : invalid) {
             try {
                 session.itemExists(path);
@@ -418,8 +424,18 @@
 
                 "jcr:con|ent",
                 "jc|r:content",
-                "con|ent");
+                "con|ent",
 
+                "jcr:content ",
+                "content ",
+                " content",
+
+                "jcr:content\t",
+                "content\t",
+                "\tcontent",
+                "con\tent"
+        );
+
         Session session = getAdminSession();
         for (String name : invalid) {
             try {
@@ -441,6 +457,13 @@
                 // success
             }
         }
+    }
+
+    @Test
+    public void testSpaceInNames() throws RepositoryException {
+        Session session = getAdminSession();
+        Node n = session.getRootNode().addNode("c o n t e n t");
+        Node n2 = session.getNode(n.getPath());
     }
 
     @Test
Index: oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java	(revision 1582265)
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/namepath/JcrPathParser.java	(revision )
@@ -206,7 +206,11 @@
                     break;
 
                 case ' ':
-                    if (state == STATE_PREFIX_START || state == STATE_NAME_START) {
+                    if (pos == len) {
+                        listener.error('\'' + jcrPath + "' is not a valid path. '" + c +
+                                                        "' not valid name end");
+                        return false;
+                    } else if (state == STATE_PREFIX_START || state == STATE_NAME_START) {
                         listener.error('\'' + jcrPath + "' is not a valid path. '" + c +
                                 "' not valid name start");
                         return false;
