Author: breser
Date: Mon May 13 22:40:07 2013
New Revision: 1482136
URL: http://svn.apache.org/r1482136
Log:
Merge the 1.8.x-r1481625 branch:
* r1481625, r1481627, r1481628, r1481631, r1481632
Properly escape control characters in an error message in libsvn_fs_fs.
Remove duplicated code.
Branch: 1.8.x-r1481625
Justification:
r1481625 and r1481627 together fix possible problems in error
message output. The other changes are nice-to-have.
Votes:
+1: danielsh, stsp (for 1.8.0, not any 1.8.x, since it adds a public API).
+1: stefan2
Modified:
subversion/branches/1.8.x/ (props changed)
subversion/branches/1.8.x/STATUS
subversion/branches/1.8.x/subversion/include/svn_path.h
subversion/branches/1.8.x/subversion/libsvn_fs_fs/tree.c
subversion/branches/1.8.x/subversion/libsvn_repos/commit.c
subversion/branches/1.8.x/subversion/libsvn_subr/path.c
Propchange: subversion/branches/1.8.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1481625,1481627-1481628,1481631-1481632
Merged /subversion/branches/1.8.x-r1481625:r1481637-1482135
Modified: subversion/branches/1.8.x/STATUS
URL:
http://svn.apache.org/viewvc/subversion/branches/1.8.x/STATUS?rev=1482136&r1=1482135&r2=1482136&view=diff
==============================================================================
--- subversion/branches/1.8.x/STATUS (original)
+++ subversion/branches/1.8.x/STATUS Mon May 13 22:40:07 2013
@@ -125,17 +125,6 @@ Approved changes:
# blocking issues. If in doubt see this link for details:
#
http://subversion.apache.org/docs/community-guide/releasing.html#release-stabilization
- * r1481625, r1481627, r1481628, r1481631, r1481632
- Properly escape control characters in an error message in libsvn_fs_fs.
- Remove duplicated code.
- Branch: 1.8.x-r1481625
- Justification:
- r1481625 and r1481627 together fix possible problems in error
- message output. The other changes are nice-to-have.
- Votes:
- +1: danielsh, stsp (for 1.8.0, not any 1.8.x, since it adds a public API).
- +1: stefan2
-
* r1477294, r1480616, r1480641, r1480642, r1480664, r1480669
Further improvements for interactive resolution of property conflicts.
Allow conflicted properties to be edited and resolved to the edited value.
Modified: subversion/branches/1.8.x/subversion/include/svn_path.h
URL:
http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/include/svn_path.h?rev=1482136&r1=1482135&r2=1482136&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/include/svn_path.h (original)
+++ subversion/branches/1.8.x/subversion/include/svn_path.h Mon May 13 22:40:07
2013
@@ -716,6 +716,14 @@ svn_path_resolve_repos_relative_url(cons
const char *repos_root_url,
apr_pool_t *pool);
+/* Return a copy of @a path, allocated from @a pool, for which control
+ * characters have been escaped using the form \NNN (where NNN is the
+ * octal representation of the byte's ordinal value).
+ *
+ * @since New in 1.8. */
+const char *
+svn_path_illegal_path_escape(const char *path, apr_pool_t *pool);
+
/** @} */
#ifdef __cplusplus
Modified: subversion/branches/1.8.x/subversion/libsvn_fs_fs/tree.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/libsvn_fs_fs/tree.c?rev=1482136&r1=1482135&r2=1482136&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/1.8.x/subversion/libsvn_fs_fs/tree.c Mon May 13
22:40:07 2013
@@ -2178,53 +2178,6 @@ fs_dir_entries(apr_hash_t **table_p,
return svn_fs_fs__dag_dir_entries(table_p, node, pool);
}
-/* Return a copy of PATH, allocated from POOL, for which newlines
- have been escaped using the form \NNN (where NNN is the
- octal representation of the byte's ordinal value). */
-static const char *
-escape_newline(const char *path, apr_pool_t *pool)
-{
- svn_stringbuf_t *retstr;
- apr_size_t i, copied = 0;
- int c;
-
- /* At least one control character:
- strlen - 1 (control) + \ + N + N + N + null . */
- retstr = svn_stringbuf_create_ensure(strlen(path) + 4, pool);
- for (i = 0; path[i]; i++)
- {
- c = (unsigned char)path[i];
- if (c != '\n')
- continue;
-
- /* First things first, copy all the good stuff that we haven't
- yet copied into our output buffer. */
- if (i - copied)
- svn_stringbuf_appendbytes(retstr, path + copied,
- i - copied);
-
- /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
- svn_stringbuf_ensure(retstr, retstr->len + 4);
- /*### The backslash separator doesn't work too great with Windows,
- but it's what we'll use for consistency with invalid utf8
- formatting (until someone has a better idea) */
- apr_snprintf(retstr->data + retstr->len, 5, "\\%03o", (unsigned char)c);
- retstr->len += 4;
-
- /* Finally, update our copy counter. */
- copied = i + 1;
- }
-
- /* Anything left to copy? */
- if (i - copied)
- svn_stringbuf_appendbytes(retstr, path + copied, i - copied);
-
- /* retstr is null-terminated either by apr_snprintf or the svn_stringbuf
- functions. */
-
- return retstr->data;
-}
-
/* Raise an error if PATH contains a newline because FSFS cannot handle
* such paths. See issue #4340. */
static svn_error_t *
@@ -2235,7 +2188,7 @@ check_newline(const char *path, apr_pool
if (c)
return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
_("Invalid control character '0x%02x' in path '%s'"),
- (unsigned char)*c, escape_newline(path, pool));
+ (unsigned char)*c, svn_path_illegal_path_escape(path, pool));
return SVN_NO_ERROR;
}
Modified: subversion/branches/1.8.x/subversion/libsvn_repos/commit.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/libsvn_repos/commit.c?rev=1482136&r1=1482135&r2=1482136&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/libsvn_repos/commit.c (original)
+++ subversion/branches/1.8.x/subversion/libsvn_repos/commit.c Mon May 13
22:40:07 2013
@@ -259,79 +259,6 @@ make_dir_baton(struct edit_baton *edit_b
return db;
}
-/* Return a copy of PATH, allocated from POOL, for which control
- characters have been escaped using the form \NNN (where NNN is the
- octal representation of the byte's ordinal value). */
-static const char *
-illegal_path_escape(const char *path, apr_pool_t *pool)
-{
- svn_stringbuf_t *retstr;
- apr_size_t i, copied = 0;
- int c;
-
- /* At least one control character:
- strlen - 1 (control) + \ + N + N + N + null . */
- retstr = svn_stringbuf_create_ensure(strlen(path) + 4, pool);
- for (i = 0; path[i]; i++)
- {
- c = (unsigned char)path[i];
- if (! svn_ctype_iscntrl(c))
- continue;
-
- /* If we got here, we're looking at a character that isn't
- supported by the (or at least, our) URI encoding scheme. We
- need to escape this character. */
-
- /* First things first, copy all the good stuff that we haven't
- yet copied into our output buffer. */
- if (i - copied)
- svn_stringbuf_appendbytes(retstr, path + copied,
- i - copied);
-
- /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
- svn_stringbuf_ensure(retstr, retstr->len + 4);
- /*### The backslash separator doesn't work too great with Windows,
- but it's what we'll use for consistency with invalid utf8
- formatting (until someone has a better idea) */
- apr_snprintf(retstr->data + retstr->len, 5, "\\%03o", (unsigned char)c);
- retstr->len += 4;
-
- /* Finally, update our copy counter. */
- copied = i + 1;
- }
-
- /* If we didn't encode anything, we don't need to duplicate the string. */
- if (retstr->len == 0)
- return path;
-
- /* Anything left to copy? */
- if (i - copied)
- svn_stringbuf_appendbytes(retstr, path + copied, i - copied);
-
- /* retstr is null-terminated either by apr_snprintf or the svn_stringbuf
- functions. */
-
- return retstr->data;
-}
-
-/* Reject paths which contain control characters (related to issue #4340). */
-static svn_error_t *
-check_valid_path(const char *path,
- apr_pool_t *pool)
-{
- const char *c;
-
- for (c = path; *c; c++)
- {
- if (svn_ctype_iscntrl(*c))
- return svn_error_createf(SVN_ERR_FS_PATH_SYNTAX, NULL,
- _("Invalid control character '0x%02x' in path '%s'"),
- (unsigned char)*c, illegal_path_escape(path, pool));
- }
-
- return SVN_NO_ERROR;
-}
-
/* This function is the shared guts of add_file() and add_directory(),
which see for the meanings of the parameters. The only extra
parameter here is IS_DIR, which is TRUE when adding a directory,
@@ -351,7 +278,8 @@ add_file_or_directory(const char *path,
svn_boolean_t was_copied = FALSE;
const char *full_path;
- SVN_ERR(check_valid_path(path, pool));
+ /* Reject paths which contain control characters (related to issue #4340). */
+ SVN_ERR(svn_path_check_valid(path, pool));
full_path = svn_fspath__join(eb->base_path,
svn_relpath_canonicalize(path, pool), pool);
Modified: subversion/branches/1.8.x/subversion/libsvn_subr/path.c
URL:
http://svn.apache.org/viewvc/subversion/branches/1.8.x/subversion/libsvn_subr/path.c?rev=1482136&r1=1482135&r2=1482136&view=diff
==============================================================================
--- subversion/branches/1.8.x/subversion/libsvn_subr/path.c (original)
+++ subversion/branches/1.8.x/subversion/libsvn_subr/path.c Mon May 13 22:40:07
2013
@@ -1167,8 +1167,8 @@ svn_path_cstring_to_utf8(const char **pa
/* Return a copy of PATH, allocated from POOL, for which control
characters have been escaped using the form \NNN (where NNN is the
octal representation of the byte's ordinal value). */
-static const char *
-illegal_path_escape(const char *path, apr_pool_t *pool)
+const char *
+svn_path_illegal_path_escape(const char *path, apr_pool_t *pool)
{
svn_stringbuf_t *retstr;
apr_size_t i, copied = 0;
@@ -1194,7 +1194,7 @@ illegal_path_escape(const char *path, ap
i - copied);
/* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
- svn_stringbuf_ensure(retstr, retstr->len + 4);
+ svn_stringbuf_ensure(retstr, retstr->len + 5);
/*### The backslash separator doesn't work too great with Windows,
but it's what we'll use for consistency with invalid utf8
formatting (until someone has a better idea) */
@@ -1232,7 +1232,8 @@ svn_path_check_valid(const char *path, a
(SVN_ERR_FS_PATH_SYNTAX, NULL,
_("Invalid control character '0x%02x' in path '%s'"),
(unsigned char)*c,
- illegal_path_escape(svn_dirent_local_style(path, pool), pool));
+ svn_path_illegal_path_escape(svn_dirent_local_style(path, pool),
+ pool));
}
}