Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h	(revision 28135)
+++ subversion/include/svn_repos.h	(working copy)
@@ -169,6 +169,14 @@
 /* Opening and creating repositories. */
 
 
+/* Check if @a path is the root of a repository by checking if the
+ * path contains the expected files and directories.  Return TRUE
+ * on errors (which would be permission errors, probably) so that
+ * we the user will see them after we try to open the repository
+ * for real.  */
+svn_boolean_t check_repos_path(const char *path,
+			       apr_pool_t *pool);
+
 /** Find the root path of the repository that contains @a path.
  *
  * If a repository was found, the path to the root of the repository
Index: subversion/mod_dav_svn/repos.c
===================================================================
--- subversion/mod_dav_svn/repos.c	(revision 28135)
+++ subversion/mod_dav_svn/repos.c	(working copy)
@@ -904,6 +904,8 @@
 }
 
 
+#include <stdio.h>
+
 AP_MODULE_DECLARE(dav_error *)
 dav_svn_split_uri(request_rec *r,
                   const char *uri_to_split,
@@ -963,10 +965,10 @@
      slash (unless it is "/").
 
      Note: given a URI of /something and a root of /some, then it is
-           impossible to be here (and end up with "thing"). This is simply
-           because we control /some and are dispatched to here for its
-           URIs. We do not control /something, so we don't get here. Or,
-           if we *do* control /something, then it is for THAT root.
+     impossible to be here (and end up with "thing"). This is simply
+     because we control /some and are dispatched to here for its
+     URIs. We do not control /something, so we don't get here. Or,
+     if we *do* control /something, then it is for THAT root.
   */
   relative = ap_stripprefix(uri, root_path);
 
@@ -1004,37 +1006,75 @@
     {
       /* SVNParentPath was used instead: assume the first component of
          'relative' is the name of a repository. */
-      const char *magic_component, *magic_end;
+      const char *magic_component = NULL, *magic_end;
 
-      /* A repository name is required here.
-         Remember that 'relative' always starts with a "/". */
-      if (relative[1] == '\0')
-        {
-          /* ### are SVN_ERR_APMOD codes within the right numeric space? */
-          return dav_new_error(r->pool, HTTP_FORBIDDEN,
-                               SVN_ERR_APMOD_MALFORMED_URI,
-                               "The URI does not contain the name "
-                               "of a repository.");
-        }
+      {
+	char *repos_path;
+	FILE* log = fopen("/tmp/moddav.log", "a+");
+	fprintf(log, "coucou\n");
 
-      magic_end = ap_strchr_c(relative + 1, '/');
-      if (!magic_end)
-        {
-          /* ### Request was for parent directory with no trailing
-             slash; we probably ought to just redirect to same with
-             trailing slash appended. */
-          magic_component = relative + 1;
-          relative = "/";
-        }
-      else
-        {
-          magic_component = apr_pstrndup(r->pool, relative + 1,
-                                         magic_end - relative - 1);
-          relative = magic_end;
-        }
+	do
+	  {
+	    /* A repository name is required here.
+	       Remember that 'relative' always starts with a "/". */
+	    if (relative[1] == '\0')
+	      {
+		/* ### are SVN_ERR_APMOD codes within the right numeric space? */
+		return dav_new_error(r->pool, HTTP_FORBIDDEN,
+				     SVN_ERR_APMOD_MALFORMED_URI,
+				     "The URI does not contain the name "
+				     "of a repository.");
+	      }
+	    
+	    magic_end = ap_strchr_c(relative + 1, '/');
+	    if (!magic_end)
+	      {
+		/* ### Request was for parent directory with no trailing
+		   slash; we probably ought to just redirect to same with
+		   trailing slash appended. */
+		if (!magic_component)
+		  {
+		    magic_component = relative + 1;
+		  }
+		else
+		  {
+		    magic_component = apr_pstrcat(r->pool, magic_component,
+						 relative, NULL);
+		  }
+		relative = "/";
+	      }
+	    else
+	      {
+		if (!magic_component)
+		  {
+		    magic_component = apr_pstrndup(r->pool, relative + 1,
+						   magic_end - relative - 1);
+		  }
+		else
+		  {
+		    char *tmp_magic_component;
 
-      /* return answer */
-      *repos_name = magic_component;
+		    tmp_magic_component = apr_pstrndup(r->pool, relative,
+						       magic_end - relative);
+		    magic_component = apr_pstrcat(r->pool, magic_component,
+						  tmp_magic_component, NULL);
+		  }
+		relative = magic_end;
+	      }
+
+	    repos_path = svn_path_join(fs_parent_path, magic_component,
+				       r->pool);
+	  }
+	while (check_repos_path(repos_path, r->pool) != TRUE);
+
+	/* return answer */
+	*repos_name = magic_component;
+
+	fprintf(log, "magic_component: %s\n", magic_component);
+	fprintf(log, "relative: %s\n", relative);
+	fprintf(log, "bye\n\n");
+	fclose(log);
+      }
     }
 
   /* We can return 'relative' at this point too. */
@@ -1136,7 +1176,7 @@
                                         "Unknown data after special_uri.");
                       }
                     
-                  break;
+		    break;
                   }
               }
             
Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c	(revision 28135)
+++ subversion/libsvn_repos/repos.c	(working copy)
@@ -1710,9 +1710,8 @@
  * on errors (which would be permission errors, probably) so that
  * we the user will see them after we try to open the repository
  * for real.  */
-static svn_boolean_t
-check_repos_path(const char *path,
-                 apr_pool_t *pool)
+svn_boolean_t check_repos_path(const char *path,
+			       apr_pool_t *pool)
 {
   svn_node_kind_t kind;
   svn_error_t *err;
