commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Federico Bonelli (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IO-499) FilenameUtils.directoryContains(String, String) gives false positive when two directories exist with equal prefixes
Date Tue, 16 Feb 2016 17:27:18 GMT
Federico Bonelli created IO-499:
-----------------------------------

             Summary: 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)

Mime
View raw message