You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Filip Defoort <fi...@cirquedigital.com> on 2006/07/21 13:43:31 UTC

[VFS] UriParser '#' in file names

Hi VFS,

I found one more 'bug' (undesired effect...): VFS can't seem to handle 
files with '#' in their
name (don't ask.. I know, but I actually had a user that created those...)

Consider the following test:

import java.io.*;
import org.apache.commons.vfs.*;
import org.apache.commons.vfs.impl.*;

public class TestHash {


   public static final void main(final String[] args) throws Exception {

            StandardFileSystemManager fileSystemManager
                 = new StandardFileSystemManager();

            fileSystemManager.setCacheStrategy(CacheStrategy.ON_RESOLVE);
            fileSystemManager.init();

            FileSystemOptions fileoptions = new FileSystemOptions();
            FileObject root = fileSystemManager.resolveFile("/tmp/", 
fileoptions);

            File dummy = new File("/tmp/test 0000 #000.txt");
            dummy.createNewFile();

            FileObject fo = root.resolveFile("test 0000 #000.txt");

            System.out.println("URL = " + fo.getURL());
            System.out.println("URL Path = " + fo.getURL().getPath());

   }

}

This test produces the following output

URL = file:///tmp/test 0000
URL Path = ///tmp/test 0000

As you can see, part following the # has been dropped from the URL, yet 
the resolveFile()
succeeded.. What's happening is that 000.txt gets stuck in the 
URL.getRef()...

I'm not sure how to handle this -- I'm guessing that the local file 
provider should encode/decode
the '#' characters appropriately so they don't get stuck in the wrong 
part of the URL...

Cheers,
- Filip




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [VFS] UriParser '#' in file names

Posted by Paul Libbrecht <pa...@activemath.org>.
My 2p observing this thread... don't make the same error as dom4j here: 
they simply said you can't make a URL out of a filename with a # hence 
open a new FileInputStream preventing any relative resolution.
I think the guilty method is file.toURL()... that one should convert the 
# sign to its equivalent %xx escape.

paul

Filip Defoort wrote:
> Done, I added both issues to JIRA.
>
> Cheers,
> - Filip
>
> Mario Ivankovits wrote:
>> Hi Filip!
>>  
>>> I found one more 'bug' (undesired effect...): VFS can't seem to handle
>>> files with '#' in their
>>> name (don't ask.. I know, but I actually had a user that created
>>> those...)
>>>     
>> How bad. VFS itself can handle the file without any hassle.
>>
>> So the filename to uri conversion needs to be done somehow smarted.
>> Could you please file a JIRA ticket on this.
>>


Re: [VFS] UriParser '#' in file names

Posted by Filip Defoort <fi...@cirquedigital.com>.
Done, I added both issues to JIRA.

Cheers,
- Filip

Mario Ivankovits wrote:
> Hi Filip!
>   
>> I found one more 'bug' (undesired effect...): VFS can't seem to handle
>> files with '#' in their
>> name (don't ask.. I know, but I actually had a user that created
>> those...)
>>     
> How bad. VFS itself can handle the file without any hassle.
>
> So the filename to uri conversion needs to be done somehow smarted.
> Could you please file a JIRA ticket on this.
>
> Ciao,
> Mario
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [VFS] UriParser '#' in file names

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Filip!
> I found one more 'bug' (undesired effect...): VFS can't seem to handle
> files with '#' in their
> name (don't ask.. I know, but I actually had a user that created
> those...)
How bad. VFS itself can handle the file without any hassle.

So the filename to uri conversion needs to be done somehow smarted.
Could you please file a JIRA ticket on this.

Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org