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 15:29:55 UTC

svn commit: r1461606 - in /subversion/branches/1.6.x-issue4340: ./ subversion/libsvn_fs/fs-loader.c subversion/tests/libsvn_fs/fs-test.c

Author: stsp
Date: Wed Mar 27 14:29:55 2013
New Revision: 1461606

URL: http://svn.apache.org/r1461606
Log:
Backport fix for issue #4340, "fs layer should reject filenames with
trailing \n", to the 1.6.x-issue4340 branch.

Merge r1461562 and r1461580 from trunk, resolving a text conflict
with the former revision, and a tree conflict with the latter revision.

* subversion/libsvn_fs/editor.c: This file doesn't exist in 1.6.x,
   so this change on trunk doesn't apply.

* subversion/libsvn_fs/fs-loader.c: Fix a text conflict caused by the
   existence of additional new tests in trunk. Tweak the test to not
   rely on SVN_TEST_ASSERT_ERROR which doesn't exist in 1.6.x, and
   adjust it to the 1.6.x C test API.

Modified:
    subversion/branches/1.6.x-issue4340/   (props changed)
    subversion/branches/1.6.x-issue4340/subversion/libsvn_fs/fs-loader.c
    subversion/branches/1.6.x-issue4340/subversion/tests/libsvn_fs/fs-test.c

Propchange: subversion/branches/1.6.x-issue4340/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1461562,1461580

Modified: subversion/branches/1.6.x-issue4340/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x-issue4340/subversion/libsvn_fs/fs-loader.c?rev=1461606&r1=1461605&r2=1461606&view=diff
==============================================================================
--- subversion/branches/1.6.x-issue4340/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/branches/1.6.x-issue4340/subversion/libsvn_fs/fs-loader.c Wed Mar 27 14:29:55 2013
@@ -351,6 +351,9 @@ path_valid(const char *path, apr_pool_t 
                                path);
     }
 
+  /* No control characters (see issue #4340). */
+  SVN_ERR(svn_path_check_valid(path, pool));
+
   /* That's good enough. */
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/1.6.x-issue4340/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x-issue4340/subversion/tests/libsvn_fs/fs-test.c?rev=1461606&r1=1461605&r2=1461606&view=diff
==============================================================================
--- subversion/branches/1.6.x-issue4340/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/branches/1.6.x-issue4340/subversion/tests/libsvn_fs/fs-test.c Wed Mar 27 14:29:55 2013
@@ -4987,6 +4987,52 @@ node_origin_rev(const char **msg,
   return SVN_NO_ERROR;
 }
 
+/* Issue 4340, "fs layer should reject filenames with trailing \n" */
+static svn_error_t *
+filename_trailing_newline(const char **msg,
+                          svn_boolean_t msg_only,
+                          svn_test_opts_t *opts,
+                          apr_pool_t *pool)
+{
+  apr_pool_t *subpool = svn_pool_create(pool);
+  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;
+
+  *msg = "filenames with trailing \\n should be rejected";
+  if (msg_only)
+    return SVN_NO_ERROR;
+
+  SVN_ERR(svn_test__create_fs(&fs, "test-filename-trailing-newline",
+                              opts, pool));
+
+  /* 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_fs_commit_txn(NULL, &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 && err->apr_err ==  SVN_ERR_FS_PATH_SYNTAX);
+  svn_error_clear(err);
+
+  /* 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 && err->apr_err ==  SVN_ERR_FS_PATH_SYNTAX);
+  svn_error_clear(err);
+
+  return SVN_NO_ERROR;
+}
+
+
 /* ------------------------------------------------------------------------ */
 
 /* The test table.  */
@@ -5030,5 +5076,6 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_PASS(set_uuid),
     SVN_TEST_PASS(node_origin_rev),
     SVN_TEST_PASS(small_file_integrity),
+    SVN_TEST_PASS(filename_trailing_newline),
     SVN_TEST_NULL
   };