Index: subversion/libsvn_subr/path.c =================================================================== --- subversion/libsvn_subr/path.c (revision 11924) +++ subversion/libsvn_subr/path.c (working copy) @@ -721,7 +721,7 @@ return NULL; /* Look for the sequence '://' */ - for (j = 0; j < len - 3; j++) + for (j = 0; j < len - 2; j++) { /* We hit a '/' before finding the sequence. */ if (path[j] == '/') @@ -1140,11 +1140,17 @@ { *(dst++) = *(src++); + /* + * In a file: URI, an empty host is implicit `localhost' and so counts as + * a first segment. Can URIs of other types have an empty host? + */ + if (uri) + ++canon_segments; #if defined(WIN32) || defined(__CYGWIN__) /* On Windows permit two leading separator characters which means an * UNC path. However, a double slash in a URI after the scheme is never * valid. */ - if (!uri && *src == '/') + else if (*src == '/') *(dst++) = *(src++); #endif /* WIN32 or Cygwin */ @@ -1180,7 +1186,7 @@ } /* Remove the trailing slash. */ - if ((canon_segments > 0 || uri) && *(dst - 1) == '/') + if (canon_segments > 0 && *(dst - 1) == '/') dst--; *dst = '\0'; Index: subversion/libsvn_ra_local/split_url.c =================================================================== --- subversion/libsvn_ra_local/split_url.c (revision 11924) +++ subversion/libsvn_ra_local/split_url.c (working copy) @@ -48,22 +48,31 @@ everything from that '/' until the end of the URL to be the absolute path portion of the URL. */ hostname = URL + 7; - path = strchr (hostname, '/'); - if (! path) - return svn_error_createf - (SVN_ERR_RA_ILLEGAL_URL, NULL, - _("Local URL '%s' contains only a hostname, no path"), URL); - - /* Treat localhost as an empty hostname. */ - if (hostname != path) + if (*hostname == '\0') { - hostname = svn_path_uri_decode (apr_pstrmemdup (pool, hostname, - path - hostname), pool); - if (strncmp (hostname, "localhost", 9) == 0) - hostname = NULL; + hostname = NULL; + path = "/"; } else - hostname = NULL; + { + path = strchr (hostname, '/'); + + /* Treat localhost as an empty hostname. */ + if (hostname != path) + { + if (path) + hostname = + svn_path_uri_decode (apr_pstrmemdup (pool, hostname, + path - hostname), pool); + else + path = "/"; + + if (strncmp (hostname, "localhost", 9) == 0) + hostname = NULL; + } + else + hostname = NULL; + } #ifndef WIN32 /* Currently, the only hostnames we are allowing on non-Win32 platforms Index: subversion/tests/libsvn_subr/path-test.c =================================================================== --- subversion/tests/libsvn_subr/path-test.c (revision 11924) +++ subversion/tests/libsvn_subr/path-test.c (working copy) @@ -154,6 +154,9 @@ "http://svn.collab.net/repos/svn", "scheme/with://slash/", "file:///path/to/repository", + "file:///", + "file://", + "file:/", }; /* Expected results of the tests. */ @@ -162,7 +165,11 @@ FALSE, TRUE, FALSE, - TRUE }; + TRUE, + TRUE, + TRUE, + FALSE, + }; *msg = "test svn_path_is_url"; @@ -652,6 +659,10 @@ { "http://hst", "http://hst" }, { "http://hst/foo/../bar","http://hst/foo/../bar" }, { "http://hst/", "http://hst" }, + { "file:///", "file://" }, + { "file://", "file://" }, + { "file:///usr/", "file:///usr" }, + { "file:///usr", "file:///usr" }, #if defined(WIN32) || defined(__CYGWIN__) /* We permit UNC paths on Windows. By definition UNC * paths must have two components so we should remove the