[ https://issues.apache.org/jira/browse/IO-499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15519730#comment-15519730 ]
ASF GitHub Bot commented on IO-499: ----------------------------------- GitHub user cagdasyelen opened a pull request: https://github.com/apache/commons-io/pull/20 [IO-499] FilenameUtils.directoryContains false positive issue IO-499 bug has been fixed. The old version was looking at if the child canonical path string starts with the parent's. However, it fails in the case of: .../top/foo .../top/foo2/b.txt since the directory path of b.txt starts with the same directory path with the one above even though the second one is a different directory(foo2). This issue is resolved by comparing the path strings of foo and foo2. You can merge this pull request into a Git repository by running: $ git pull https://github.com/cagdasyelen/commons-io io499-fix Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-io/pull/20.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #20 ---- commit fd95ccde6310bfee7314744d879c597882cb3381 Author: Cagdas Yelen <cag...@utexas.edu> Date: 2016-09-24T22:21:37Z [IO-499] FilenameUtils.directoryContains false positive issue is resolved ---- > 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)