From: Ben Reser Date: Sun, 6 Oct 2013 01:08:51 +0000 (+0000) Subject: Fix PR 55397: dav_resource->uri treated as an unparsed uri. X-Git-Tag: 2.5.0-alpha~4971 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4de0b69f7f4272be734ebddd111b480174bc2525;p=apache Fix PR 55397: dav_resource->uri treated as an unparsed uri. 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 --- diff --git a/modules/dav/fs/repos.c b/modules/dav/fs/repos.c index 6c4c44b1fd..cf17e22a08 100644 --- a/modules/dav/fs/repos.c +++ b/modules/dav/fs/repos.c @@ -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) { diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index 9299220b2a..93346250c1 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -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); } diff --git a/modules/dav/main/mod_dav.h b/modules/dav/main/mod_dav.h index 74b421b534..62c21f057f 100644 --- a/modules/dav/main/mod_dav.h +++ b/modules/dav/main/mod_dav.h @@ -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 */