[ 
https://issues.apache.org/jira/browse/IO-499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15555171#comment-15555171
 ] 

Federico Bonelli commented on IO-499:
-------------------------------------

@cagdasyelen I'm afraid this patch doesn't consider the case when the file path 
is composed using '\' separators (aka Windows case). We should adapt it to that 
case before pulling the patch.

> FilenameUtils.directoryContains(String, String) gives false positive when two 
> directories exist with equal prefixes
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: IO-499
>                 URL: https://issues.apache.org/jira/browse/IO-499
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Federico Bonelli
>            Priority: Minor
>
> In a folder layout as such:
> {code}
> /foo/a.txt
> /foo2/b.txt
> {code}
> The result of invoking directoryContains is wrong:
> {code}
> FilenameUtils.directoryContains("/foo", "/foo2/b.txt"); // returns true
> {code}
> even if "/foo" and "/foo2/b.txt" are the canonical paths, they start with the 
> same characters, and the current implementation of the method fails.
> As workaround we are currently appending a path separator '/' to the first 
> argument.
> It is noteworthy that the current implementation of 
> FileUtils.directoryContains() reveals this issue because it uses the 
> File.getCanonicalPath() to obtain the String paths of "/foo" and 
> "/foo2/b.txt".



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to