You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Michael Smith <ms...@xn.com.au> on 2001/02/15 05:25:06 UTC

More URL (un)escaping

A second try, after sending it to a typoed address:
Firstly, thanks for your work on adding url escaping and unescaping to
the server side, Remy.

However, this isn't quite enough - we need similar things in the client
libraries too, otherwise things break.

It seems silly to have two copies of all this stuff, though - would it
be sensible to have a shared package of generic utility classes between
the server and client? I suspect that there would be more things than
just URL encoding/decoding that would be useful here.

Anyway, since I'm not sure how you want to structure that code (maybe a
second copy is just easier), the attached patch just shows where the
code needs to be used - it's not intended to be applied as-is, because
it doesn't actually include the code that it calls.

First one: close reading of the RFCs shows that the href header must be
URL encoded. Most implementations will work regardless, but the server
now (correctly) encodes it, so we must decode it.

--- XMLResponseMethodBase.java  2001/02/11 21:04:58     1.6
+++ XMLResponseMethodBase.java  2001/02/15 00:12:19
@@ -365,7 +365,7 @@
         public String getHref() {
             Element href = getFirstElement("DAV:", "href");
             if (href != null) {
-                return DOMUtils.getTextValue(href);
+                return URLDecode(DOMUtils.getTextValue(href));
             } else {
                 return "";
             }


Secondly, this one. This is needed so that the client generates the
correct output in generateRequestLine().
I suspect (but am not certain. I don't know that bit of the code too
well) that the Destination header needs to be similarly encoded in
CopyMethod and MoveMethod. I can't easily test that though, since the
command line client doesn't deal with things like spaces in filenames.

--- WebdavMethodBase.java       2001/02/05 18:20:14     1.10
+++ WebdavMethodBase.java       2001/02/15 00:14:42
@@ -221,7 +222,7 @@
         if ((path == null) || (path.equals(""))) {
             this.path = "/";
         } else {
-            this.path = path;
+            this.path = URLEncode(path);
         }
     }

Thanks,

Michael