[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]Re: URL problem

From: Paul Marculescu <paul_at_p16.pub.ro>
Date: 2002-06-03 04:23:16 CEST

Branko ?ibej wrote:
>
> As I've said before:
>
> * First, we have to replace our URL parsing code with the utilities
> from apr-util
> * Then fix apr-util to do the right thing on Windows.
>

I made a patch for apr_uri.c and send it on dev@apr.apache.org.
I also made a little patch for libsvn_ra_local/split_url.c to use
apr_uri_parse().

Index: split_url.c
===================================================================
RCS file: e:/cvsroot/cvstest/split_url.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 split_url.c
--- split_url.c 2002/06/03 02:14:45 1.1.1.1
+++ split_url.c 2002/06/03 02:21:31
@@ -20,7 +20,7 @@
 #include <assert.h>
 #include <string.h>
 #include "svn_pools.h"
-
+#include <apr_uri.h>
 svn_error_t *
 svn_ra_local__split_URL (const svn_string_t **repos_path,
                          const svn_string_t **fs_path,
@@ -28,16 +28,17 @@
                          apr_pool_t *pool)
 {
   svn_error_t *err;
- svn_stringbuf_t *url;
- char *hostname, *url_data, *path;
+ svn_stringbuf_t *url;
   apr_pool_t *subpool = svn_pool_create (pool);
   svn_repos_t *repos;
+ apr_uri_t uri;
+
+ apr_uri_parse( pool, URL->data, &uri );
 
- /* Verify that the URL is well-formed (loosely) */
- url_data = URL->data;
+ /* Verify that the URL is well-formed (loosely) */
 
   /* First, check for the "file://" prefix. */
- if (memcmp ("file://", url_data, 7))
+ if (!uri.scheme || memcmp ("file", uri.scheme, 4))
     return svn_error_create
       (SVN_ERR_RA_ILLEGAL_URL, 0, NULL, pool,
        ("svn_ra_local__split_URL: URL does not contain `file://'
prefix"));
@@ -45,23 +46,21 @@
   /* 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. */
- hostname = url_data + 7;
- path = strchr (hostname, '/');
- if (! path)
+ absolute path portion of the URL. */
+ if (!uri.path)
     return svn_error_create
       (SVN_ERR_RA_ILLEGAL_URL, 0, NULL, pool,
        ("svn_ra_local__split_URL: URL contains only a hostname, no
path"));
 
   /* Currently, the only hostnames we are allowing are the empty
      string and 'localhost' */
- if ((hostname != path) && (memcmp (hostname, "localhost", 9)))
+ if (uri.hostname[0] != 0 && memcmp (uri.hostname, "localhost", 9))
     return svn_error_create
       (SVN_ERR_RA_ILLEGAL_URL, 0, NULL, pool,
        ("svn_ra_local__split_URL: URL contains unsupported hostname"));
 
   /* Duplicate the URL, starting at the top of the path */
- url = svn_stringbuf_create ((const char *)path, subpool);
+ url = svn_stringbuf_create ((const char *)uri.path, subpool);
 
   /* Loop, trying to open a repository at URL. If this fails, remove
      the last component from the URL, then try again. */
@@ -101,7 +100,7 @@
      REPOS_PATH. FS_PATH is what we've hacked off in the process. We
      need to make sure these are allocated in the -original- pool. */
   *repos_path = svn_string_create_from_buf (url, pool);
- *fs_path = svn_string_create (path + url->len, pool);
+ *fs_path = svn_string_create (uri.path + url->len, pool);
 
   /* Destroy our temporary memory pool. */
   svn_pool_destroy (subpool);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jun 3 03:23:45 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.