]> granicus.if.org Git - apache/commitdiff
Fix PR 55397: dav_resource->uri treated as an unparsed uri.
authorBen Reser <breser@apache.org>
Sun, 6 Oct 2013 01:08:51 +0000 (01:08 +0000)
committerBen Reser <breser@apache.org>
Sun, 6 Oct 2013 01:08:51 +0000 (01:08 +0000)
The change made for PR 54611 caused this field to be treated as
unescaped.  mod_dav_svn however, provided escaped URIs.  Essentially
breaking support for paths with non-URI safe characters in SVN.

Adjust the code so that dav_resource->uri is assumed to be escaped and
adjust mod_dav_fs so that it uses escaped URIs in this field.

* modules/dav/fs/repos.c
  (dav_fs_get_resource): Use the unparsed_uri to contruct the resource uri.

* modules/dav/main/mod_dav.c
  (dav_xml_escape_uri): Do not uri escape, just handle xml escaping.
  (dav_created): Assume that locn if provided is escaped.
  (dav_method_copymove, dav_method_bind): Use the unparsed_uri on the request
    when calling dav_created() to adjust to locn assuming it is escaped.

* modules/dav/main/mod_dav.h
  (dav_resource): Document that uri is escaped.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1529559 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/fs/repos.c
modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h

index 6c4c44b1fdef8a3088f6e8b38d5193767dbcb0c7..cf17e22a08a9943f754236b3073aaca22a73f13d 100644 (file)
@@ -717,13 +717,13 @@ static dav_error * dav_fs_get_resource(
     resource->pool = r->pool;
 
     /* make sure the URI does not have a trailing "/" */
-    len = strlen(r->uri);
-    if (len > 1 && r->uri[len - 1] == '/') {
-        s = apr_pstrmemdup(r->pool, r->uri, len-1);
+    len = strlen(r->unparsed_uri);
+    if (len > 1 && r->unparsed_uri[len - 1] == '/') {
+        s = apr_pstrmemdup(r->pool, r->unparsed_uri, len-1);
         resource->uri = s;
     }
     else {
-        resource->uri = r->uri;
+        resource->uri = r->unparsed_uri;
     }
 
     if (r->finfo.filetype != APR_NOFILE) {
index 9299220b2a555e7be4694d6d59d01baf94d5438d..93346250c16a6e476657d74990e30ab4b986380b 100644 (file)
@@ -397,11 +397,9 @@ static int dav_error_response_tag(request_rec *r,
  */
 static const char *dav_xml_escape_uri(apr_pool_t *p, const char *uri)
 {
-    const char *e_uri = ap_escape_uri(p, uri);
-
     /* check the easy case... */
-    if (ap_strchr_c(e_uri, '&') == NULL)
-        return e_uri;
+    if (ap_strchr_c(uri, '&') == NULL)
+        return uri;
 
     /* there was a '&', so more work is needed... sigh. */
 
@@ -409,7 +407,7 @@ static const char *dav_xml_escape_uri(apr_pool_t *p, const char *uri)
      * Note: this is a teeny bit of overkill since we know there are no
      * '<' or '>' characters, but who cares.
      */
-    return apr_xml_quote_string(p, e_uri, 0);
+    return apr_xml_quote_string(p, uri, 0);
 }
 
 
@@ -605,7 +603,8 @@ static int dav_handle_err(request_rec *r, dav_error *err,
     return DONE;
 }
 
-/* handy function for return values of methods that (may) create things */
+/* handy function for return values of methods that (may) create things.
+ * locn if provided is assumed to be escaped. */
 static int dav_created(request_rec *r, const char *locn, const char *what,
                        int replaced)
 {
@@ -613,8 +612,6 @@ static int dav_created(request_rec *r, const char *locn, const char *what,
 
     if (locn == NULL) {
         locn = r->unparsed_uri;
-    } else {
-        locn = ap_escape_uri(r->pool, locn);
     }
 
     /* did the target resource already exist? */
@@ -3012,7 +3009,7 @@ static int dav_method_copymove(request_rec *r, int is_move)
     }
 
     /* return an appropriate response (HTTP_CREATED or HTTP_NO_CONTENT) */
-    return dav_created(r, lookup.rnew->uri, "Destination",
+    return dav_created(r, lookup.rnew->unparsed_uri, "Destination",
                        resnew_state == DAV_RESOURCE_EXISTS);
 }
 
@@ -4618,7 +4615,7 @@ static int dav_method_bind(request_rec *r)
 
     /* return an appropriate response (HTTP_CREATED) */
     /* ### spec doesn't say what happens when destination was replaced */
-    return dav_created(r, lookup.rnew->uri, "Binding", 0);
+    return dav_created(r, lookup.rnew->unparsed_uri, "Binding", 0);
 }
 
 
index 74b421b5341884a76d2a26cf87170ea5532c5230..62c21f057f30d99f5fddd8d98e67cb17710beaea 100644 (file)
@@ -386,7 +386,7 @@ typedef struct dav_resource {
                          * REGULAR and WORKSPACE resources,
                          * and is always 1 for WORKING */
 
-    const char *uri;    /* the URI for this resource */
+    const char *uri;    /* the escaped URI for this resource */
 
     dav_resource_private *info;         /* the provider's private info */