You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/06/23 13:26:00 UTC
[jira] [Closed] (IO-499) FilenameUtils.directoryContains(String, String) gives false positive when two directories exist with equal prefixes
[ https://issues.apache.org/jira/browse/IO-499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory closed IO-499.
------------------------------
Resolution: Abandoned
Closing: PR closed.
> 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
(v8.20.7#820007)