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 2010/06/28 15:27:46 UTC
svn commit: r958571 - in /subversion/trunk/subversion:
libsvn_subr/dirent_uri.c tests/libsvn_subr/dirent_uri-test.c
Author: julianfoad
Date: Mon Jun 28 13:27:46 2010
New Revision: 958571
URL: http://svn.apache.org/viewvc?rev=958571&view=rev
Log:
Fix a file:// URL decoding bug.
* subversion/libsvn_subr/dirent_uri.c
(svn_uri_get_dirent_from_file_url): Don't treat any host name beginning
with "localhost" as the local host, only if it is that string exactly.
* subversion/tests/libsvn_subr/dirent_uri-test.c
(test_dirent_from_file_url_errors): New test, to catch some bad file:///
URLs including the above case.
(test_funcs): Add the new test.
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=958571&r1=958570&r2=958571&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Mon Jun 28 13:27:46 2010
@@ -2314,7 +2314,7 @@ svn_uri_get_dirent_from_file_url(const c
{
hostname = svn_path_uri_decode(apr_pstrmemdup(pool, hostname,
path - hostname), pool);
- if (strncmp(hostname, "localhost", 9) == 0)
+ if (strcmp(hostname, "localhost") == 0)
hostname = NULL;
}
else
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=958571&r1=958570&r2=958571&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 13:27:46 2010
@@ -2714,6 +2714,38 @@ test_dirent_from_file_url(apr_pool_t *po
return SVN_NO_ERROR;
}
+
+static svn_error_t *
+test_dirent_from_file_url_errors(apr_pool_t *pool)
+{
+ const char *bad_file_urls[] = {
+ /* error if scheme is not "file" */
+ "http://localhost/dir",
+ "file+ssh://localhost/dir",
+#ifndef SVN_USE_DOS_PATHS
+ "file://localhostwrongname/dir", /* error if host name not "localhost" */
+#endif
+ };
+ int i;
+
+ for (i = 0; i < COUNT_OF(bad_file_urls); i++)
+ {
+ const char *result;
+ svn_error_t *err;
+
+ err = svn_uri_get_dirent_from_file_url(&result, bad_file_urls[i],
+ pool);
+
+ if (err == NULL)
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+ "svn_relpath_internal_style(\"%s\") did "
+ "not return an error",
+ bad_file_urls[i]);
+ svn_error_clear(err);
+ }
+
+ return SVN_NO_ERROR;
+}
/* The test table. */
@@ -2808,5 +2840,7 @@ struct svn_test_descriptor_t test_funcs[
"test svn_relpath_internal_style"),
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"),
SVN_TEST_NULL
};
Re: svn commit: r958571 - in /subversion/trunk/subversion:
libsvn_subr/dirent_uri.c tests/libsvn_subr/dirent_uri-test.c
Posted by Greg Stein <gs...@gmail.com>.
On Mon, Jun 28, 2010 at 09:27, <ju...@apache.org> wrote:
> Author: julianfoad
> Date: Mon Jun 28 13:27:46 2010
> New Revision: 958571
>
> URL: http://svn.apache.org/viewvc?rev=958571&view=rev
> Log:
> Fix a file:// URL decoding bug.
>
> * subversion/libsvn_subr/dirent_uri.c
> (svn_uri_get_dirent_from_file_url): Don't treat any host name beginning
> with "localhost" as the local host, only if it is that string exactly.
The point here is that the "file:///localhost:1234/" style of
construction is forbidden in file URLs.
>...
Cheers,
-g