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

Re: Filenames with trailing newlines wreak havoc

From: Stefan Sperling <stsp_at_elego.de>
Date: Wed, 27 Mar 2013 13:37:12 +0100

On Wed, Mar 27, 2013 at 01:35:30PM +0100, Stefan Sperling wrote:
> Let's face it, the FS API promise people are upholding in this discussion
> has been broken for years.

FWIW, here's the patch I was trying to use:

Index: subversion/libsvn_repos/fs-wrap.c
===================================================================
--- subversion/libsvn_repos/fs-wrap.c (revision 1461542)
+++ subversion/libsvn_repos/fs-wrap.c (working copy)
@@ -42,6 +42,34 @@
 
 /*** Commit wrappers ***/
 
+/* Verify names of changed paths within the transaction TXN.
+ *
+ * This was added for issue 4340, "repos layer should reject filenames with
+ * trailing \n", but in addition to newlines it rejects any characters
+ * Subversion clients would reject when adding new files to version control. */
+static svn_error_t *
+verify_changed_path_names(svn_fs_txn_t *txn, apr_pool_t *pool)
+{
+ apr_pool_t *iterpool;
+ svn_fs_root_t *txn_root;
+ apr_hash_t *changed_paths;
+ apr_hash_index_t *hi;
+
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+ SVN_ERR(svn_fs_paths_changed2(&changed_paths, txn_root, pool));
+
+ iterpool = svn_pool_create(pool);
+ for (hi = apr_hash_first(pool, changed_paths); hi; hi = apr_hash_next(hi))
+ {
+ const char *path = svn__apr_hash_index_key(hi);
+
+ SVN_ERR(svn_path_check_valid(path, iterpool));
+ }
+ svn_pool_destroy(iterpool);
+
+ return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_repos_fs_commit_txn(const char **conflict_p,
                         svn_repos_t *repos,
@@ -57,6 +85,9 @@ svn_repos_fs_commit_txn(const char **conflict_p,
 
   *new_rev = SVN_INVALID_REVNUM;
 
+ /* Verify names of changed paths. */
+ SVN_ERR(verify_changed_path_names(txn, pool));
+
   /* Run pre-commit hooks. */
   SVN_ERR(svn_fs_txn_name(&txn_name, txn, pool));
   SVN_ERR(svn_repos__hooks_pre_commit(repos, txn_name, pool));
Received on 2013-03-27 13:37:55 CET

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