You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2015/12/08 12:14:24 UTC

svn commit: r1718566 - /subversion/trunk/subversion/libsvn_repos/commit.c

Author: rhuijben
Date: Tue Dec  8 11:14:23 2015
New Revision: 1718566

URL: http://svn.apache.org/viewvc?rev=1718566&view=rev
Log:
In the libsvn_repos commit handling: Use modern uri functions instead
of a completely nonstandard form for relpath calculations.

* subversion/libsvn_repos/commit.c
  (edit_baton): Store url in canonical form.
  (add_file_or_directory): Ensure copyfrom_path is in canonical form.
    Use standard functions.
  (svn_repos_get_commit_editor5): Canonicalize incoming url.

Modified:
    subversion/trunk/subversion/libsvn_repos/commit.c

Modified: subversion/trunk/subversion/libsvn_repos/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/commit.c?rev=1718566&r1=1718565&r2=1718566&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/commit.c (original)
+++ subversion/trunk/subversion/libsvn_repos/commit.c Tue Dec  8 11:14:23 2015
@@ -73,7 +73,7 @@ struct edit_baton
   svn_repos_t *repos;
 
   /* URL to the root of the open repository. */
-  const char *repos_url_decoded;
+  const char *repos_root_url;
 
   /* The name of the repository (here for convenience). */
   const char *repos_name;
@@ -324,7 +324,6 @@ add_file_or_directory(const char *path,
       const char *fs_path;
       svn_fs_root_t *copy_root;
       svn_node_kind_t kind;
-      size_t repos_url_len;
       svn_repos_authz_access_t required;
 
       /* Copy requires recursive write access to the destination path
@@ -345,14 +344,15 @@ add_file_or_directory(const char *path,
 
       /* For now, require that the url come from the same repository
          that this commit is operating on. */
-      copy_path = svn_path_uri_decode(copy_path, subpool);
-      repos_url_len = strlen(eb->repos_url_decoded);
-      if (strncmp(copy_path, eb->repos_url_decoded, repos_url_len) != 0)
+      copy_path = svn_uri_canonicalize(copy_path, subpool);
+      copy_path = svn_uri_skip_ancestor(eb->repos_root_url, copy_path,
+                                        subpool);
+      if (!copy_path)
         return svn_error_createf
           (SVN_ERR_FS_GENERAL, NULL,
            _("Source url '%s' is from different repository"), copy_path);
 
-      fs_path = apr_pstrdup(subpool, copy_path + repos_url_len);
+      fs_path = svn_fspath__canonicalize(copy_path, pool);
 
       /* Now use the "fs_path" as an absolute path within the
          repository to make the copy from. */
@@ -1009,7 +1009,9 @@ svn_repos_get_commit_editor5(const svn_d
   struct edit_baton *eb;
   svn_delta_shim_callbacks_t *shim_callbacks =
                                     svn_delta_shim_callbacks_default(pool);
-  const char *repos_url = svn_path_uri_encode(repos_url_decoded, pool);
+  /* Our api contract explicitly requires a not canonical url here.
+     ### Should fix that when revving this api */
+  const char *repos_url = svn_uri_canonicalize(repos_url_decoded, pool);
 
   /* Do a global authz access lookup.  Users with no write access
      whatsoever to the repository don't get a commit editor. */
@@ -1051,7 +1053,7 @@ svn_repos_get_commit_editor5(const svn_d
   eb->authz_baton = authz_baton;
   eb->base_path = svn_fspath__canonicalize(base_path, subpool);
   eb->repos = repos;
-  eb->repos_url_decoded = repos_url_decoded;
+  eb->repos_root_url = repos_url;
   eb->repos_name = svn_dirent_basename(svn_repos_path(repos, subpool),
                                        subpool);
   eb->fs = svn_repos_fs(repos);