jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1525630 - in /jackrabbit/branches/2.6: ./ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java
Date Mon, 23 Sep 2013 15:45:08 GMT
Author: reschke
Date: Mon Sep 23 15:45:08 2013
New Revision: 1525630

URL: http://svn.apache.org/r1525630
Log:
JCR-3582 improve exception message for non-SP whitespace in node names (ported to 2.6)

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

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1525629

Modified: jackrabbit/branches/2.6/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java?rev=1525630&r1=1525629&r2=1525630&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/PathParser.java
Mon Sep 23 15:45:08 2013
@@ -251,9 +251,11 @@ public class PathParser {
 
         while (pos <= len) {
             char c = pos == len ? EOF : jcrPath.charAt(pos);
+            char rawCharacter = c;
             pos++;
             // special check for whitespace
             if (c != ' ' && Character.isWhitespace(c)) {
+                rawCharacter = c;
                 c = '\t';
             }
             switch (c) {
@@ -394,7 +396,9 @@ public class PathParser {
 
                 case '\t':
                     if (state != STATE_IDENTIFIER) {
-                        throw new MalformedPathException("'" + jcrPath + "' is not a valid
path. Whitespace not a allowed in name.");
+                        String message = String.format("'%s' is not a valid path. Whitespace
other than SP (U+0020) not a allowed in a name, but U+%04x was found at position %d.",
+                                            jcrPath, (long) rawCharacter, pos - 1);
+                        throw new MalformedPathException(message);
                     }
                 case '*':
                 case '|':

Modified: jackrabbit/branches/2.6/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java?rev=1525630&r1=1525629&r2=1525630&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/conversion/PathParserTest.java
Mon Sep 23 15:45:08 2013
@@ -259,6 +259,7 @@ public class PathParserTest extends Test
         paths.add("/:");
         paths.add("/*");
         paths.add("//");
+        paths.add("foo\u3000bar"); // non-ASCII whitespace
 
         for (String jcrPath : paths) {
             try {
@@ -382,9 +383,9 @@ public class PathParserTest extends Test
             } catch (MalformedPathException e) {
                 // ok
             }
-        }       
+        }
     }
-    
+
     public void testIdentifierCheckFormat() throws RepositoryException {
         DummyIdentifierResolver idResolver = new DummyIdentifierResolver();
         List<String> valid = idResolver.getValidIdentifiers();



Mime
View raw message