You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Federico Bonelli (JIRA)" <ji...@apache.org> on 2016/02/16 18:27:18 UTC
[jira] [Created] (IO-499) FilenameUtils.directoryContains(String,
String) gives false positive when two directories exist with equal prefixes
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)