You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jens Scheffler (JIRA)" <ji...@apache.org> on 2008/11/13 21:48:44 UTC

[jira] Created: (VFS-225) File name parsing issues in layered file systems

File name parsing issues in layered file systems
------------------------------------------------

                 Key: VFS-225
                 URL: https://issues.apache.org/jira/browse/VFS-225
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 1.0
         Environment: Windows XP SP2 - but also assuming in other environments
            Reporter: Jens Scheffler


The "!" character is used as delimiter for e.g. ZIP file access as VFS component.

When trying to traverse a layered file, e.g. traversing a ZIP content and the ZIP contains a file with a "!" in the file name itself then a FileSystemException appears - it seems that the parsing routine for layered filenames is stumbling over the "!" character.

Exception trace for a test VFS component:
org.apache.commons.vfs.FileSystemException: Incorrect file system URI "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!/" in name "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!.txt", was expecting "syncdb:file:///C:/Temp/test.xml!/".
	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:274)
	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
	at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
	at de.jensscheffler.ftpsync.db.SyncFileSystemTest.treeCopy(SyncFileSystemTest.java:87)
	(...)

As the accessing code was just traversing a folder tree with no chance to handle this, is there any alternative for traversing through these layered file systems when the content contains special characters?

Maybe the approach for parsing needs to be enhanced also, I could offer some help but maybe need a hint to contribute a fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (VFS-225) File name parsing issues in layered file systems

Posted by "Jens Scheffler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/VFS-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647838#action_12647838 ] 

Jens Scheffler commented on VFS-225:
------------------------------------

Good idea. Tried to nail down a very very simple example but failed to reproduce the same Exception using ZipFileSystem. But maybe I can contribute a bit more information from my debugging session.

Test Preparation:
Create a simple (even empty) text file called "Important!!.txt" in a folder called "Dir". ZIP the "Dir" folder into "Archive.zip" and place the ZIP into "C:\Temp" so that the resulting URI would look like:
zip:file:///C:/Temp/Archive.zip!/Dir/Important!!!.txt

If you execute the following code:
            FileSystemManager mgr = VFS.getManager();
            FileObject f = mgr.resolveFile("zip:file:///C:/Temp/Archive.zip!/");
            FileObject[] content = f.findFiles(Selectors.SELECT_ALL);
            for (FileObject item : content) {
                System.out.println(item.toString());
            }
...you will NOT find the file. A problem in ZipFileSystem prevents the same exceptions which I initially reported here due to pre-parsing of whole ZIP file and validation of references.

Nevertheless in the VFS provider which I'm currently writing I have from the same root cause the described exception.

Root of the problem seems to be the parsing of layered file system names, a string scanner goes backwards and tried to find the last "!" char in the file name.
It is in LayeredFileNameParser.extractRootName(StringBuffer)

Please tell me if I should contribute something further here.

> File name parsing issues in layered file systems
> ------------------------------------------------
>
>                 Key: VFS-225
>                 URL: https://issues.apache.org/jira/browse/VFS-225
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Windows XP SP2 - but also assuming in other environments
>            Reporter: Jens Scheffler
>
> The "!" character is used as delimiter for e.g. ZIP file access as VFS component.
> When trying to traverse a layered file, e.g. traversing a ZIP content and the ZIP contains a file with a "!" in the file name itself then a FileSystemException appears - it seems that the parsing routine for layered filenames is stumbling over the "!" character.
> Exception trace for a test VFS component:
> org.apache.commons.vfs.FileSystemException: Incorrect file system URI "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!/" in name "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!.txt", was expecting "syncdb:file:///C:/Temp/test.xml!/".
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:274)
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
> 	at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
> 	at de.jensscheffler.ftpsync.db.SyncFileSystemTest.treeCopy(SyncFileSystemTest.java:87)
> 	(...)
> As the accessing code was just traversing a folder tree with no chance to handle this, is there any alternative for traversing through these layered file systems when the content contains special characters?
> Maybe the approach for parsing needs to be enhanced also, I could offer some help but maybe need a hint to contribute a fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (VFS-225) File name parsing issues in layered file systems

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/VFS-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647864#action_12647864 ] 

James Carman commented on VFS-225:
----------------------------------

I wouldn't suggest writing a test case that uses "c:/" at all.  Our automated builds don't run on windows machines, so those tests would fail.  What's wrong with creating a ZIP file and including in as a test resource.  Then use that to test the logic?

> File name parsing issues in layered file systems
> ------------------------------------------------
>
>                 Key: VFS-225
>                 URL: https://issues.apache.org/jira/browse/VFS-225
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Windows XP SP2 - but also assuming in other environments
>            Reporter: Jens Scheffler
>
> The "!" character is used as delimiter for e.g. ZIP file access as VFS component.
> When trying to traverse a layered file, e.g. traversing a ZIP content and the ZIP contains a file with a "!" in the file name itself then a FileSystemException appears - it seems that the parsing routine for layered filenames is stumbling over the "!" character.
> Exception trace for a test VFS component:
> org.apache.commons.vfs.FileSystemException: Incorrect file system URI "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!/" in name "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!.txt", was expecting "syncdb:file:///C:/Temp/test.xml!/".
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:274)
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
> 	at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
> 	at de.jensscheffler.ftpsync.db.SyncFileSystemTest.treeCopy(SyncFileSystemTest.java:87)
> 	(...)
> As the accessing code was just traversing a folder tree with no chance to handle this, is there any alternative for traversing through these layered file systems when the content contains special characters?
> Maybe the approach for parsing needs to be enhanced also, I could offer some help but maybe need a hint to contribute a fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (VFS-225) File name parsing issues in layered file systems

Posted by "Jens Scheffler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/VFS-225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Scheffler updated VFS-225:
-------------------------------

    Attachment: LayeredFileNameParsingTest.java

Please find a Unit Test attached which is generating the test data.

The test crates a temporary ZIP file with 2 files
- Dir/SomeFile.txt
- Dir/Important!!.txt
Then it uses commons-vfs to scan through the files.
During opening the ZIP file to function to resolve base URI is called and as of generating the wrong base URI as described above the file is not added to the ZIP container during init.

Hope this helps.

> File name parsing issues in layered file systems
> ------------------------------------------------
>
>                 Key: VFS-225
>                 URL: https://issues.apache.org/jira/browse/VFS-225
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Windows XP SP2 - but also assuming in other environments
>            Reporter: Jens Scheffler
>         Attachments: LayeredFileNameParsingTest.java
>
>
> The "!" character is used as delimiter for e.g. ZIP file access as VFS component.
> When trying to traverse a layered file, e.g. traversing a ZIP content and the ZIP contains a file with a "!" in the file name itself then a FileSystemException appears - it seems that the parsing routine for layered filenames is stumbling over the "!" character.
> Exception trace for a test VFS component:
> org.apache.commons.vfs.FileSystemException: Incorrect file system URI "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!/" in name "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!.txt", was expecting "syncdb:file:///C:/Temp/test.xml!/".
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:274)
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
> 	at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
> 	at de.jensscheffler.ftpsync.db.SyncFileSystemTest.treeCopy(SyncFileSystemTest.java:87)
> 	(...)
> As the accessing code was just traversing a folder tree with no chance to handle this, is there any alternative for traversing through these layered file systems when the content contains special characters?
> Maybe the approach for parsing needs to be enhanced also, I could offer some help but maybe need a hint to contribute a fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (VFS-225) File name parsing issues in layered file systems

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/VFS-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12647508#action_12647508 ] 

James Carman commented on VFS-225:
----------------------------------

The first step would be to write up a test case that exhibits the problem.  That way, we'll know if we do get it fixed.

> File name parsing issues in layered file systems
> ------------------------------------------------
>
>                 Key: VFS-225
>                 URL: https://issues.apache.org/jira/browse/VFS-225
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Windows XP SP2 - but also assuming in other environments
>            Reporter: Jens Scheffler
>
> The "!" character is used as delimiter for e.g. ZIP file access as VFS component.
> When trying to traverse a layered file, e.g. traversing a ZIP content and the ZIP contains a file with a "!" in the file name itself then a FileSystemException appears - it seems that the parsing routine for layered filenames is stumbling over the "!" character.
> Exception trace for a test VFS component:
> org.apache.commons.vfs.FileSystemException: Incorrect file system URI "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!/" in name "syncdb:file:///C:/Temp/test.xml!/c/temp/Maps/Important to Read!!.txt", was expecting "syncdb:file:///C:/Temp/test.xml!/".
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:274)
> 	at org.apache.commons.vfs.provider.AbstractFileSystem.resolveFile(AbstractFileSystem.java:267)
> 	at org.apache.commons.vfs.provider.AbstractFileObject.resolveFile(AbstractFileObject.java:670)
> 	at de.jensscheffler.ftpsync.db.SyncFileSystemTest.treeCopy(SyncFileSystemTest.java:87)
> 	(...)
> As the accessing code was just traversing a folder tree with no chance to handle this, is there any alternative for traversing through these layered file systems when the content contains special characters?
> Maybe the approach for parsing needs to be enhanced also, I could offer some help but maybe need a hint to contribute a fix.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.