Details
-
Bug
-
Resolution: Done
-
Major
-
5.2.6.Final
-
None
Description
This is the method in GridFile that is executed to compare paths. However, it doesn't compare the parent with a trailing `File.separator`, so all children with a path that starts with the parent path (even without a File.separator) are considered children.
E.g:
src/main/java src/main/java-NOT-A-CHILD
That means this actually returns true:
isChildOf("src/main/java", "src/main/java-NOT-A-CHILD")
protected static boolean isChildOf(String parent, String child) { if (parent == null || child == null) return false; if (!child.startsWith(parent)) return false; if (child.length() <= parent.length()) return false; int from = parent.equals(SEPARATOR) ? parent.length() : parent.length() + 1; // if(from-1 > child.length()) // return false; String[] comps = Util.components(child.substring(from), SEPARATOR); return comps != null && comps.length <= 1; }