Author: julianfoad
Date: Mon Jun 28 15:05:56 2010
New Revision: 958598
URL: http://svn.apache.org/viewvc?rev=958598&view=rev
Log:
Fix svn_uri_get_dirent_from_file_url()'s handling of the root path '/'.
* subversion/libsvn_subr/dirent_uri.c
(svn_uri_get_dirent_from_file_url): Rewrite the finding of hostname and
path so that an empty path is treated as '/' even if it comes after a
hostname.
* subversion/tests/libsvn_subr/dirent_uri-test.c
(test_funcs): Remove the XFAIL from test_dirent_from_file_url().
Modified:
subversion/trunk/subversion/libsvn_subr/dirent_uri.c
subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=958598&r1=958597&r2=958598&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Mon Jun 28 15:05:56
2010
@@ -2289,35 +2289,25 @@ svn_uri_get_dirent_from_file_url(const c
_("Local URL '%s' does not contain 'file://' "
"prefix"), url);
- /* Then, skip what's between the "file://" prefix and the next
- occurance of '/' -- this is the hostname, and we are considering
- everything from that '/' until the end of the URL to be the
- absolute path portion of the URL.
+ /* Find the HOSTNAME portion and the PATH portion of the URL. The host
+ name is between the "file://" prefix and the next occurence of '/'. We
+ are considering everything from that '/' until the end of the URL to be
+ the absolute path portion of the URL.
If we got just "file://", treat it the same as "file:///". */
hostname = url + 7;
+ path = strchr(hostname, '/');
+ if (path)
+ hostname = apr_pstrmemdup(pool, hostname, path - hostname);
+ else
+ path = "/";
+
+ /* URI-decode HOSTNAME, and set it to NULL if it is "" or "localhost". */
if (*hostname == '\0')
- {
- path = "/";
- hostname = NULL;
- }
+ hostname = NULL;
else
{
- 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)
- {
- hostname = svn_path_uri_decode(apr_pstrmemdup(pool, hostname,
- path - hostname),
pool);
- if (strcmp(hostname, "localhost") == 0)
- hostname = NULL;
- }
- else
+ hostname = svn_path_uri_decode(hostname, pool);
+ if (strcmp(hostname, "localhost") == 0)
hostname = NULL;
}
Modified: subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=958598&r1=958597&r2=958598&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Mon Jun 28
15:05:56 2010
@@ -2840,7 +2840,7 @@ struct svn_test_descriptor_t test_funcs[
"test svn_dirent_internal_style"),
SVN_TEST_PASS2(test_relpath_internal_style,
"test svn_relpath_internal_style"),
- SVN_TEST_XFAIL2(test_dirent_from_file_url,
+ SVN_TEST_PASS2(test_dirent_from_file_url,
"test svn_uri_get_dirent_from_file_url"),
SVN_TEST_PASS2(test_dirent_from_file_url_errors,
"test svn_uri_get_dirent_from_file_url errors"),