[jira] [Commented] (IO-499) FilenameUtils.directoryContains(String, String) gives false positive when two directories exist with equal prefixes

2016-10-07 Thread Federico Bonelli (JIRA)

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

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)


[jira] [Created] (IO-499) FilenameUtils.directoryContains(String, String) gives false positive when two directories exist with equal prefixes

2016-02-16 Thread Federico Bonelli (JIRA)
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)


[jira] [Created] (IO-498) FileUtils.directoryContains(File, File) returns wrong results when the file name contains unreadable characters

2016-02-12 Thread Federico Bonelli (JIRA)
Federico Bonelli created IO-498:
---

 Summary: FileUtils.directoryContains(File, File) returns wrong 
results when the file name contains unreadable characters
 Key: IO-498
 URL: https://issues.apache.org/jira/browse/IO-498
 Project: Commons IO
  Issue Type: Bug
Affects Versions: 2.4
 Environment: linux
Reporter: Federico Bonelli


When testing for FileUtils.directoryContains(File, File) on a file which is in 
fact contained in the given directory but has odd characters in the name, the 
method returns wrong results.

This file:
{code:title=File name}
bof@testcorso2015:~/tmp/test$ ls col* | xxd
000: 636f 6c74 e00a   colt..
{code}

fails to be recognized as belonging to the current directory in this simple 
snippet of code:

{code:title=Snippet|borderStyle=solid}
File[] files = new File(".").listFiles();
for(File f : files){
 System.out.println("contains " + f + " = " + 
FileUtils.directoryContains(new File("."), f));
}
{code}




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


[jira] [Commented] (IO-498) FileUtils.directoryContains(File, File) returns wrong results when the file name contains unreadable characters

2016-02-12 Thread Federico Bonelli (JIRA)

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

Federico Bonelli commented on IO-498:
-

Is it worth noticing that in this case the method fails because of what I think 
being a JVM bug.

The snippet
{code}
File[] files = new File(".").listFiles();
for(File f : files){
 System.out.println("exists: " + f.exists());
}
{code}

shows that with an ill formed name as the one I'm using the File class is not 
able to work properly.
The same file object returned by listFiles() is said to be unexistant.

> FileUtils.directoryContains(File, File) returns wrong results when the file 
> name contains unreadable characters
> ---
>
> Key: IO-498
> URL: https://issues.apache.org/jira/browse/IO-498
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.4
> Environment: linux
>Reporter: Federico Bonelli
>
> When testing for FileUtils.directoryContains(File, File) on a file which is 
> in fact contained in the given directory but has odd characters in the name, 
> the method returns wrong results.
> This file:
> {code:title=File name}
> bof@testcorso2015:~/tmp/test$ ls col* | xxd
> 000: 636f 6c74 e00a   colt..
> {code}
> fails to be recognized as belonging to the current directory in this simple 
> snippet of code:
> {code:title=Snippet|borderStyle=solid}
> File[] files = new File(".").listFiles();
> for(File f : files){
>  System.out.println("contains " + f + " = " + 
> FileUtils.directoryContains(new File("."), f));
> }
> {code}



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


[jira] [Commented] (IO-498) FileUtils.directoryContains(File, File) returns wrong results when the file name contains unreadable characters

2016-02-12 Thread Federico Bonelli (JIRA)

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

Federico Bonelli commented on IO-498:
-

Yes it is on a UTF8 system.

I'm afraid you are right, this is nothing we can solve in the Commons IO.

I wish this was fixable, but I agree to close it.

> FileUtils.directoryContains(File, File) returns wrong results when the file 
> name contains unreadable characters
> ---
>
> Key: IO-498
> URL: https://issues.apache.org/jira/browse/IO-498
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.4
> Environment: linux
>Reporter: Federico Bonelli
>Priority: Minor
>
> When testing for FileUtils.directoryContains(File, File) on a file which is 
> in fact contained in the given directory but has odd characters in the name, 
> the method returns wrong results.
> This file:
> {code:title=File name}
> bof@testcorso2015:~/tmp/test$ ls col* | xxd
> 000: 636f 6c74 e00a   colt..
> {code}
> fails to be recognized as belonging to the current directory in this simple 
> snippet of code:
> {code:title=Snippet|borderStyle=solid}
> File[] files = new File(".").listFiles();
> for(File f : files){
>  System.out.println("contains " + f + " = " + 
> FileUtils.directoryContains(new File("."), f));
> }
> {code}



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