jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1239512 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/util/PathUtils.java test/java/org/apache/jackrabbit/mk/util/PathTest.java
Date Thu, 02 Feb 2012 09:57:57 GMT
Author: stefan
Date: Thu Feb  2 09:57:57 2012
New Revision: 1239512

URL: http://svn.apache.org/viewvc?rev=1239512&view=rev
Log:
fix PathUtils.isAncestor

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java?rev=1239512&r1=1239511&r2=1239512&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/util/PathUtils.java
Thu Feb  2 09:57:57 2012
@@ -324,7 +324,13 @@ public class PathUtils {
     public static boolean isAncestor(String ancestor, String path) {
         assertValid(ancestor);
         assertValid(path);
-        return path.startsWith(ancestor) && getDepth(path) > getDepth(ancestor);
+        if (ancestor.length() == 0 || path.length() == 0) {
+            return false;
+        }
+        if (!denotesRoot(ancestor)) {
+            ancestor += "/";
+        }
+        return path.startsWith(ancestor);
     }
 
     /**

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java?rev=1239512&r1=1239511&r2=1239512&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/PathTest.java
Thu Feb  2 09:57:57 2012
@@ -149,6 +149,7 @@ public class PathTest extends TestCase {
         assertTrue(PathUtils.isAncestor("/" + parent, "/" + parent + "/" + child));
         assertFalse(PathUtils.isAncestor(parent, child));
         assertFalse(PathUtils.isAncestor("/" + parent, "/" + parent + "123"));
+        assertFalse(PathUtils.isAncestor("/" + parent, "/" + parent + "123/foo"));
 
         // relativize
         assertEquals("", PathUtils.relativize("/", "/"));



Mime
View raw message