The way the comparison is performed in WebdavResource is correct. The
real problem is org.apache.util.HttpURL. That's why I alreay have
partly moved to using the URI stuff from Commons Httpclient. A
complete switch would require some API changes, maybe this should be
discussed in the light of a 2.0 release or a separation of the client
part.
You run into trouble if you are using the HttpURL constructors which
do NOT take an already escaped URL string. To work around the problem,
you could use something like
new WebdavResource("http://user:[EMAIL PROTECTED]/jim%20beam/test-10").
It's also safe to use the WebdavResource objects you get by calling
getChildResources().
As I'm planning to drop usage of org.apache.util.HttpURL in the
future, I don't bother trying to fix it. So please use the workaround
if you can.
Regards,
Ingo.
> > Hi Ivan,
> >
> > I can't reproduce your problem. As you can see from the last line of
> > your patch, the escaped pathnames are compared not the unescaped ones.
>
> Ahhh... apologies to everyone, I should have looked more carefully.
>
> I fixed this many moons ago, and when I worked on it there were no
> getEscapedPath() calls, they were introduced only 2 revisions ago (in 1.67, end
> of July). Before it was only getPath(), which was causing problems if the URL
> contained spaces or any other "reserved" characters (according to RFC 2068,
> section 3.2.1), and my fix worked then. I blindly assumed there were no changes
> to this part of the code since then.
>
> But introducing getEscapedPath() in revision 1.67 only partially fixed the
> problem; it fixes the case with spaces, but it breaks if you have a collection
> with dashes or undescores, as James experienced. Now, the reason for this latest
> breakage is apparently a bug in org.apache.slide.uril.HttpURL.getEscapedPath(),
> which escapes more characters then it needs to (dash and underscore are safe
> characters according to RFC 2068).
>
> Here is my updated patch:
>
> diff -u -r1.69 WebdavResource.java
> --- src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
> +++ src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
> @@ -918,9 +918,10 @@
>
> boolean itself = false;
> String href = response.getHref();
> + href = org.apache.util.URIUtil.unescape(href);
> if (!href.startsWith("/"))
> - href = HttpURL.getEscapedPath(href);
> - String httpURLPath = httpURL.getEscapedPath();
> + href = HttpURL.getPath(href);
> + String httpURLPath = httpURL.getPath();
> int compared = httpURLPath.compareTo(href);
> // Compare with the href path and requested-path itself.
> if (compared == 0 || compared == -1 && href.endsWith("/") ||
>
>
> Basically, we normalize both httpURLPath and href to unescaped form before
> comparing them.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]