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/05/19 12:17:07 UTC
svn commit: r1484261 - in /subversion/branches/1.6.x-issue4340: ./
subversion/libsvn_fs_fs/tree.c
Author: stsp
Date: Sun May 19 10:17:07 2013
New Revision: 1484261
URL: http://svn.apache.org/r1484261
Log:
On the 1.6.x-issue4340 branch, filter control characters from an error message.
This corresponds to r1481627 on trunk, but the svn_path_illegal_path_escape()
API function used in that commit is not available in 1.6.x. So I've manually
marked the revision as merged using a --record-only merge.
* subversion/libsvn_fs_fs/tree.c
(): Include svn_ctype.h for svn_ctype_iscntrl().
(escape_newline): Rename to...
(illegal_path_escape): ... this, and tweak the code to match the current
implementation of svn_path_illegal_path_escape() on trunk.
(check_newline): Update caller.
Modified:
subversion/branches/1.6.x-issue4340/ (props changed)
subversion/branches/1.6.x-issue4340/subversion/libsvn_fs_fs/tree.c
Propchange: subversion/branches/1.6.x-issue4340/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1481627
Modified: subversion/branches/1.6.x-issue4340/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.6.x-issue4340/subversion/libsvn_fs_fs/tree.c?rev=1484261&r1=1484260&r2=1484261&view=diff
==============================================================================
--- subversion/branches/1.6.x-issue4340/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/1.6.x-issue4340/subversion/libsvn_fs_fs/tree.c Sun May 19 10:17:07 2013
@@ -43,6 +43,7 @@
#include "svn_mergeinfo.h"
#include "svn_fs.h"
#include "svn_props.h"
+#include "svn_ctype.h"
#include "fs.h"
#include "err.h"
@@ -1810,11 +1811,11 @@ fs_dir_entries(apr_hash_t **table_p,
return svn_fs_fs__dag_dir_entries(table_p, node, pool, pool);
}
-/* Return a copy of PATH, allocated from POOL, for which newlines
- have been escaped using the form \NNN (where NNN is the
+/* 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 *
-escape_newline(const char *path, apr_pool_t *pool)
+illegal_path_escape(const char *path, apr_pool_t *pool)
{
svn_stringbuf_t *retstr;
apr_size_t i, copied = 0;
@@ -1826,9 +1827,13 @@ escape_newline(const char *path, apr_poo
for (i = 0; path[i]; i++)
{
c = (unsigned char)path[i];
- if (c != '\n')
+ 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)
@@ -1836,7 +1841,7 @@ escape_newline(const char *path, apr_poo
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) */
@@ -1847,6 +1852,10 @@ escape_newline(const char *path, apr_poo
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);
@@ -1869,7 +1878,7 @@ check_newline(const char *path, apr_pool
if (*c == '\n')
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, illegal_path_escape(path, pool));
}
return SVN_NO_ERROR;