[infinispan-issues] [JBoss JIRA] (ISPN-3502) GridFile.isChildOf() incorrectly compares file paths.

Pedro Ruivo (JIRA) jira-events at lists.jboss.org
Tue Sep 17 14:00:04 EDT 2013


     [ https://issues.jboss.org/browse/ISPN-3502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pedro Ruivo updated ISPN-3502:
------------------------------

    Issue Type: Bug  (was: Feature Request)

    
> GridFile.isChildOf() incorrectly compares file paths.
> -----------------------------------------------------
>
>                 Key: ISPN-3502
>                 URL: https://issues.jboss.org/browse/ISPN-3502
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Core API
>    Affects Versions: 5.2.6.Final
>            Reporter: Lincoln Baxter III
>            Assignee: Lincoln Baxter III
>             Fix For: 6.0.0.Beta1
>
>
> 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:
> {code}
> src/main/java
> src/main/java-NOT-A-CHILD 
> {code}
> That means this actually returns true:
> {code}
> isChildOf("src/main/java", "src/main/java-NOT-A-CHILD")
> {code}
> {code}
>    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;
>    }{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list