Hi all,

[[
Fix issue #4263: svnrdump: E125005: Cannot accept non-LF line endings in
'svn:log' property

Fix to ensure that no "\r" characters are present in revision or node
props.

In the case of "\r\n" character sequences, the "\r" is removed.

In the case of "\r" characters which are not followed by "\n", the "\r"
is replaced by a "\n" character.

* subversion/svnrdump/svnrdump.h:
  (svn_rdump__normalize_prop): New function declaration.

* subversion/svnrdump/util.c:
  (svn_rdump__normalize_prop): New function to allow "svnrdump load" to
                               use existing logic
  (svn_rdump__normalize_props): Refactored to move logic into
                                (svn_rdump__normalize_prop)

* subversion/svnrdump/load_editor.c:
  (set_revision_property): Added call to (svn_rdump__normalize_prop)
  (set_node_property): Added call to (svn_rdump__normalize_prop)

* subversion/tests/cmdline/svnrdump_tests.py:
  (copy_bad_line_endings_load): Removed "XFail" decorator

]]]

regards,

Gabriela
Index: subversion/svnrdump/util.c
===================================================================
--- subversion/svnrdump/util.c	(revision 1423235)
+++ subversion/svnrdump/util.c	(working copy)
@@ -31,12 +31,30 @@
 
 
 svn_error_t *
+svn_rdump__normalize_prop(const char *name, 
+			  const svn_string_t **value,
+                          apr_pool_t *result_pool)
+{
+  if (svn_prop_needs_translation(name))
+    {
+      const char *cstring;
+
+      SVN_ERR(svn_subst_translate_cstring2((*value)->data, &cstring,
+					   "\n", TRUE,
+					   NULL, FALSE,
+					   result_pool));
+
+      *value = svn_string_create(cstring, result_pool);
+    }
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_rdump__normalize_props(apr_hash_t **normal_props,
                            apr_hash_t *props,
                            apr_pool_t *result_pool)
 {
   apr_hash_index_t *hi;
-
   *normal_props = apr_hash_make(result_pool);
 
   for (hi = apr_hash_first(result_pool, props); hi;
@@ -47,13 +65,8 @@ svn_rdump__normalize_props(apr_hash_t **normal_pro
 
       if (svn_prop_needs_translation(key))
         {
-          const char *cstring;
-
-          SVN_ERR(svn_subst_translate_cstring2(value->data, &cstring,
-                                               "\n", TRUE,
-                                               NULL, FALSE,
-                                               result_pool));
-          value = svn_string_create(cstring, result_pool);
+	  SVN_ERR(svn_rdump__normalize_prop(key, &value,
+					    result_pool));
         }
 
       apr_hash_set(*normal_props, key, APR_HASH_KEY_STRING, value);
Index: subversion/svnrdump/svnrdump.h
===================================================================
--- subversion/svnrdump/svnrdump.h	(revision 1423235)
+++ subversion/svnrdump/svnrdump.h	(working copy)
@@ -92,6 +92,9 @@ svn_rdump__load_dumpstream(svn_stream_t *stream,
                            apr_pool_t *pool);
 
 
+
+
+
 /* Normalize the line ending style of the values of properties in PROPS
  * that "need translation" (according to svn_prop_needs_translation(),
  * currently all svn:* props) so that they contain only LF (\n) line endings.
@@ -106,6 +109,16 @@ svn_rdump__normalize_props(apr_hash_t **normal_pro
                            apr_hash_t *props,
                            apr_pool_t *result_pool);
 
+/* Normalize the line ending style of a single property that "needs
+ * translation" (according to svn_prop_needs_translation(),
+ * currently all svn:* props) so that they contain only LF (\n) line endings.
+ */
+svn_error_t *
+svn_rdump__normalize_prop(const char *name,
+			  const svn_string_t **value,
+			  apr_pool_t *result_pool);
+
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: subversion/svnrdump/load_editor.c
===================================================================
--- subversion/svnrdump/load_editor.c	(revision 1423235)
+++ subversion/svnrdump/load_editor.c	(working copy)
@@ -855,6 +855,8 @@ set_revision_property(void *baton,
 {
   struct revision_baton *rb = baton;
 
+  SVN_ERR(svn_rdump__normalize_prop(name, &value, rb->pool));
+  
   SVN_ERR(svn_repos__validate_prop(name, value, rb->pool));
 
   if (rb->rev > 0)
@@ -934,6 +936,8 @@ set_node_property(void *baton,
         }
     }
 
+  SVN_ERR(svn_rdump__normalize_prop(name, &value, pool));
+
   SVN_ERR(svn_repos__validate_prop(name, value, pool));
 
   switch (nb->kind)
Index: subversion/tests/cmdline/svnrdump_tests.py
===================================================================
--- subversion/tests/cmdline/svnrdump_tests.py	(revision 1423235)
+++ subversion/tests/cmdline/svnrdump_tests.py	(working copy)
@@ -358,7 +358,6 @@ def copy_bad_line_endings_dump(sbox):
                 expected_dumpfile_name="copy-bad-line-endings.expected.dump",
                 bypass_prop_validation=True)
 
-@XFail()
 @Issue(4263)
 def copy_bad_line_endings_load(sbox):
   "load: inconsistent line endings in svn:* props"

Reply via email to