You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2019/09/13 12:24:02 UTC

svn commit: r1866899 - in /subversion/trunk/subversion/libsvn_ra_serf: options.c util.c

Author: julianfoad
Date: Fri Sep 13 12:24:01 2019
New Revision: 1866899

URL: http://svn.apache.org/viewvc?rev=1866899&view=rev
Log:
When following an HTTP redirect, use the Location header URL exactly.

Previously we canonicalized the redirect URL, which could lead to a redirect
loop. Then Subversion would report a redirect loop as the error, potentially
hiding a more interesting error such as when the target is not in fact a
Subversion repository.

A manual test case (on a non-repository):
  before:
    $ svn ls https://archive.apache.org/dist
    Redirecting to URL 'https://archive.apache.org/dist':
    Redirecting to URL 'https://archive.apache.org/dist':
    svn: E195019: Redirect cycle detected for URL 'https://archive.apache.org/dist'

  after:
    $ svn ls https://archive.apache.org/dist
    Redirecting to URL 'https://archive.apache.org/dist/':
    svn: E170013: Unable to connect to a repository at URL 'https://archive.apache.org/dist/'
    svn: E175003: The server at 'https://archive.apache.org/dist/' does not support the HTTP/DAV protocol

* subversion/libsvn_ra_serf/options.c
  (svn_ra_serf__exchange_capabilities): Don't canonicalize the redirect URL.

* subversion/libsvn_ra_serf/util.c
  (response_get_location): Don't canonicalize the redirect URL.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/options.c
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1866899&r1=1866898&r2=1866899&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/options.c Fri Sep 13 12:24:01 2019
@@ -575,8 +575,7 @@ svn_ra_serf__exchange_capabilities(svn_r
         }
       else if (svn_path_is_url(opt_ctx->handler->location))
         {
-          *corrected_url = svn_uri_canonicalize(opt_ctx->handler->location,
-                                                result_pool);
+          *corrected_url = apr_pstrdup(result_pool, opt_ctx->handler->location);
         }
       else
         {
@@ -589,9 +588,7 @@ svn_ra_serf__exchange_capabilities(svn_r
           apr_uri_t corrected_URI = serf_sess->session_url;
 
           corrected_URI.path = (char *)corrected_url;
-          *corrected_url = svn_uri_canonicalize(
-                              apr_uri_unparse(scratch_pool, &corrected_URI, 0),
-                              result_pool);
+          *corrected_url = apr_uri_unparse(result_pool, &corrected_URI, 0);
         }
 
       return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1866899&r1=1866898&r2=1866899&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Fri Sep 13 12:24:01 2019
@@ -1116,19 +1116,17 @@ response_get_location(serf_bucket_t *res
         return NULL;
 
       /* Replace the path path with what we got */
-      uri.path = (char*)svn_urlpath__canonicalize(location, scratch_pool);
+      uri.path = apr_pstrdup(scratch_pool, location);
 
       /* And make APR produce a proper full url for us */
-      location = apr_uri_unparse(scratch_pool, &uri, 0);
-
-      /* Fall through to ensure our canonicalization rules */
+      return apr_uri_unparse(result_pool, &uri, 0);
     }
   else if (!svn_path_is_url(location))
     {
       return NULL; /* Any other formats we should support? */
     }
 
-  return svn_uri_canonicalize(location, result_pool);
+  return apr_pstrdup(result_pool, location);
 }