commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <tcu...@apache.org>
Subject Re: [vfs] directory traversing with webdav
Date Fri, 10 Jun 2005 11:18:54 GMT
> Oh, I see, I thought you mean VFS should throw this exception in general.
> Sure, just for findFile this could be possible.
> I'll see what junit mean to your suggestion ;-)

Seems to work for us.
Would be great if you could add it to trunk.

But I came across another thing:

The traversal does not work correctly when there
are space (I assume special characters in general)
in the directory name / URI. Seems like the traversal
is missing a call to the URI encoder.


Caused by: java.lang.IllegalArgumentException: Invalid uri
'/~tcurdt/test/bla/b lub': escaped absolute path not valid
	at
org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:307)
	at
org.apache.webdav.lib.methods.HttpRequestBodyMethodBase.<init>(HttpRequestBodyMethodBase.java:74)
	at
org.apache.webdav.lib.methods.XMLResponseMethodBase.<init>(XMLResponseMethodBase.java:89)
	at
org.apache.webdav.lib.methods.OptionsMethod.<init>(OptionsMethod.java:121)
	at
org.apache.commons.vfs.provider.webdav.WebdavFileObject.setDavResource(WebdavFileObject.java:122)
	at
org.apache.commons.vfs.provider.webdav.WebdavFileObject.doListChildrenResolved(WebdavFileObject.java:307)



This should fix it:

Index:
/Users/tcurdt/dev/jakarta-commons-vfs/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
===================================================================
---
/Users/tcurdt/dev/jakarta-commons-vfs/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
(revision 189583)
+++
/Users/tcurdt/dev/jakarta-commons-vfs/src/java/org/apache/commons/vfs/provider/webdav/WebdavFileObject.java
(working copy)
@@ -18,6 +18,7 @@
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.util.URIUtil;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileType;
@@ -38,6 +39,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.URI;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -119,7 +121,7 @@
         // if (bCheckExists)
         {
             /* now fill the dav properties */
-            final OptionsMethod optionsMethod = new
OptionsMethod(getName().getPath());
+            final OptionsMethod optionsMethod = new
OptionsMethod(URIUtil.encodePath(getName().getPath()));
             optionsMethod.setFollowRedirects(true);
             final int status =
fileSystem.getClient().executeMethod(optionsMethod);
             if (status < 200 || status > 299)

cheers
--
Torsten

Mime
View raw message