subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1461580 - in /subversion/trunk/subversion: libsvn_fs/editor.c libsvn_fs/fs-loader.c tests/libsvn_fs/fs-test.c
Date Wed, 27 Mar 2013 13:47:04 GMT
Author: stsp
Date: Wed Mar 27 13:47:04 2013
New Revision: 1461580

URL: http://svn.apache.org/r1461580
Log:
Fix issue #4340, "fs layer should reject filenames with trailing \n",
by making the FS layer reject new paths which contain control characters.

To some degree, this change breaks compatibility with the officially
documented rules for path names in the FS API (see svn_fs.h, the
comment starting with "Directory entry names and directory paths")

However, given the impracticalities of managing repositories which contain
paths with control characters such as \n (see dev@ thread linked from
issue #4340), I don't expect this to really hurt anyone. Subversion clients
have never allowed paths containing control characters to be added to version
control, so I decided not to single out \n during server-side validation.

* subversion/libsvn_fs/editor.c
  (can_create): Reject paths containing control characters.

* subversion/libsvn_fs/fs-loader.c
  (svn_fs__path_valid): Reject paths containing control characters.

* subversion/tests/libsvn_fs/fs-test.c
  (test_funcs): Remove XFAIL marker from filename_trailing_newline test.

Modified:
    subversion/trunk/subversion/libsvn_fs/editor.c
    subversion/trunk/subversion/libsvn_fs/fs-loader.c
    subversion/trunk/subversion/tests/libsvn_fs/fs-test.c

Modified: subversion/trunk/subversion/libsvn_fs/editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/editor.c?rev=1461580&r1=1461579&r2=1461580&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/editor.c (original)
+++ subversion/trunk/subversion/libsvn_fs/editor.c Wed Mar 27 13:47:04 2013
@@ -28,6 +28,7 @@
 #include "svn_pools.h"
 #include "svn_fs.h"
 #include "svn_props.h"
+#include "svn_path.h"
 
 #include "svn_private_config.h"
 
@@ -287,6 +288,9 @@ can_create(svn_fs_root_t *txn_root,
   svn_node_kind_t kind;
   const char *cur_fspath;
 
+  /* Reject paths which contain control characters (see issue #4340). */
+  SVN_ERR(svn_path_check_valid(fspath, scratch_pool));
+
   SVN_ERR(svn_fs_check_path(&kind, txn_root, fspath, scratch_pool));
   if (kind == svn_node_none)
     return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1461580&r1=1461579&r2=1461580&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Wed Mar 27 13:47:04 2013
@@ -396,6 +396,9 @@ svn_fs__path_valid(const char *path, apr
                                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/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1461580&r1=1461579&r2=1461580&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Wed Mar 27 13:47:04 2013
@@ -4962,11 +4962,11 @@ filename_trailing_newline(const svn_test
   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);
+  SVN_TEST_ASSERT_ERROR(err, SVN_ERR_FS_PATH_SYNTAX);
 
   /* 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);
+  SVN_TEST_ASSERT_ERROR(err, SVN_ERR_FS_PATH_SYNTAX);
 
   return SVN_NO_ERROR;
 }
@@ -5052,7 +5052,7 @@ struct svn_test_descriptor_t test_funcs[
                        "test svn_fs_node_history"),
     SVN_TEST_OPTS_PASS(delete_fs,
                        "test svn_fs_delete_fs"),
-    SVN_TEST_OPTS_XFAIL(filename_trailing_newline,
+    SVN_TEST_OPTS_PASS(filename_trailing_newline,
                        "filenames with trailing \\n should be rejected"),
     SVN_TEST_NULL
   };



Mime
View raw message