You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/03/27 12:38:07 UTC

svn commit: r1461535 - /subversion/trunk/subversion/tests/libsvn_repos/repos-test.c

Author: stsp
Date: Wed Mar 27 11:38:07 2013
New Revision: 1461535

URL: http://svn.apache.org/r1461535
Log:
Add an XFAIL test for issue 4340, "repos layer should reject filenames with
trailing \n". 

* subversion/tests/libsvn_repos/repos-test.c
  (filename_trailing_newline, test_funcs): New test.

Modified:
    subversion/trunk/subversion/tests/libsvn_repos/repos-test.c

Modified: subversion/trunk/subversion/tests/libsvn_repos/repos-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_repos/repos-test.c?rev=1461535&r1=1461534&r2=1461535&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_repos/repos-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_repos/repos-test.c Wed Mar 27 11:38:07 2013
@@ -3164,6 +3164,46 @@ test_delete_repos(const svn_test_opts_t 
 
   return SVN_NO_ERROR;
 }
+
+/* Issue 4340, "repos layer should reject filenames with trailing \n" */
+static svn_error_t *
+filename_trailing_newline(const svn_test_opts_t *opts,
+                          apr_pool_t *pool)
+{
+  apr_pool_t *subpool = svn_pool_create(pool);
+  svn_repos_t *repos;
+  svn_fs_t *fs;
+  svn_fs_txn_t *txn;
+  svn_fs_root_t *txn_root, *root;
+  svn_revnum_t youngest_rev = 0;
+  svn_error_t *err;
+
+  /* Create the repository. */
+  SVN_ERR(svn_test__create_repos(&repos, "test-filename-trailing-newline",
+                                 opts, pool));
+  fs = svn_repos_fs(repos);
+
+  /* Revision 1:  Add a directory /foo  */
+  SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_fs_make_dir(txn_root, "/foo", subpool));
+  SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, subpool));
+  SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev));
+  svn_pool_clear(subpool);
+
+  /* Attempt to copy /foo to "/bar\n". This should fail. */
+  SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, subpool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, subpool));
+  SVN_ERR(svn_fs_revision_root(&root, fs, youngest_rev, subpool));
+  err = svn_fs_copy(root, "/foo", txn_root, "/bar\n", subpool);
+  SVN_TEST_ASSERT(err != SVN_NO_ERROR);
+
+  /* Attempt to create a file /foo/baz\n. This should fail. */
+  err = svn_fs_make_file(txn_root, "/foo/baz\n", subpool);
+  SVN_TEST_ASSERT(err != SVN_NO_ERROR);
+
+  return SVN_NO_ERROR;
+}
 
 /* The test table.  */
 
@@ -3208,5 +3248,7 @@ struct svn_test_descriptor_t test_funcs[
                        "test issue 4060"),
     SVN_TEST_OPTS_PASS(test_delete_repos,
                        "test svn_repos_delete"),
+    SVN_TEST_OPTS_XFAIL(filename_trailing_newline,
+                       "filenames with trailing \\n should be rejected"),
     SVN_TEST_NULL
   };