commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rami Ojares <rami.oja...@elisa.fi>
Subject [vfs] parsing uri
Date Mon, 07 Mar 2005 20:46:27 GMT
In DefaultLocalFileProvider is a method findLocalFile.
It's idea is to convert File object into FileObject object.

public FileObject findLocalFile(final File file)
    throws FileSystemException
{
    // TODO - tidy this up, should build file object straight from the file
        return findFile(null, "file:" + file.getAbsolutePath(), null);
}

It calls findFile that is in AbstractOriginatingFileProvider

The signature of the method is
findFile(final FileObject baseFile, final String uri, final 
FileSystemOptions fileSystemOptions) throws FileSystemException

Notice the name of the second argument: 'uri'

Here's the problem:

Let's say I have file whose absolute path is

"/foo/%bar"

It's uri should be file:/foo/%25bar but now it just is file:/foo/%bar 
which is not a correct uri
leading to an exception later when the system tries to decode the uri 
and complains that
Invalid URI escape sequence "%ba"

So the method should be

public FileObject findLocalFile(final File file)
    throws FileSystemException
{
    // TODO - tidy this up, should build file object straight from the file
        return findFile(null, "file:" + 
ENCODE_URI_SOMEHOW(file.getAbsolutePath()), null);
}

the same remark applies to

public FileObject findLocalFile(final String name)
    throws FileSystemException
{
    // TODO - tidy this up, no need to turn the name into an absolute URI,
    // and then straight back again
    return findFile(null, "file:" + name, null);
}

- Rami Ojares

Ps. I hope this remark is valid since I haven't updated the sources for 
a long time.

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


Mime
View raw message