commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Legner (JIRA)" <>
Subject [jira] [Commented] (VFS-398) FtpFileObject.getChildren() fails when a folder contains a file with a colon in the name
Date Thu, 24 Sep 2015 20:41:05 GMT


Simon Legner commented on VFS-398:

[~markjleonard], thank you for the clarification.

Consider a file {{/foo:bar:baz/foo:bar}} relative to FTP root and calling {{VFS.getManager().resolveFile("ftp://localhost:2121/foo:bar:baz").getChildren()}}.

In {{org.apache.commons.vfs2.impl.DefaultFileSystemManager#resolveName(org.apache.commons.vfs2.FileName,
java.lang.String, org.apache.commons.vfs2.NameScope)}} from the method parameter {{name}}
(which is considered relative to the root) a scheme is extracted. This yields {{foo}} as scheme
and subsequent test {{(scheme == null && buffer.charAt(0) != FileName.SEPARATOR_CHAR)}}
is negative.

The scheme extraction for the relative {{name}} has been integrated in revision 780730.  I
wonder why.

> FtpFileObject.getChildren() fails when a folder contains a file with a colon in the name
> ----------------------------------------------------------------------------------------
>                 Key: VFS-398
>                 URL:
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Connecting via FTP to a host running SunOS 5.10
>            Reporter: Mark Leonard
>            Priority: Blocker
> In line 767 of the UriParser's extractScheme() method is
>         String scheme = UriParser.extractScheme(buffer.toString());
> This code was added in revision 780730
> It is not clear to me why this change was made.
> For the FTP provider, buffer contains a plain file name (i.e. without a path and definitely
not in URI form)
> A colon is a valid character for a file name.
> However a colon will be interpreted as a URI scheme name.
> This causes an exception when the resolved path is checked using AbstractFileName.checkName()
> Sample code:
> FileObject fo = VFS.getManager().resolveFile("ftp://user:pass@host/some/path/some.file");
> fo.getParent().getChildren();
> If /some/path/ contains a child such as PREFIX:SUFFIX then an exception is thrown:
> Exception in thread "main" org.apache.commons.vfs2.FileSystemException: Invalid descendent
file name "PREFIX:SUFFIX".
> 	at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveName(
> 	at org.apache.commons.vfs2.provider.AbstractFileObject.getChildren(
> 	at org.apache.commons.vfs2.provider.ftp.FtpFileObject.getChildren(
> Therefore calling code is unable to list the children of the specified folder.

This message was sent by Atlassian JIRA

View raw message