subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1481817 - in /subversion/branches/1.7.x-issue4340: ./ subversion/libsvn_fs_fs/tree.c
Date Mon, 13 May 2013 12:19:54 GMT
Author: stsp
Date: Mon May 13 12:19:54 2013
New Revision: 1481817

URL: http://svn.apache.org/r1481817
Log:
On the 1.7.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.7.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.7.x-issue4340/   (props changed)
    subversion/branches/1.7.x-issue4340/subversion/libsvn_fs_fs/tree.c

Propchange: subversion/branches/1.7.x-issue4340/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1481627

Modified: subversion/branches/1.7.x-issue4340/subversion/libsvn_fs_fs/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4340/subversion/libsvn_fs_fs/tree.c?rev=1481817&r1=1481816&r2=1481817&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4340/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/1.7.x-issue4340/subversion/libsvn_fs_fs/tree.c Mon May 13 12:19:54
2013
@@ -44,6 +44,7 @@
 #include "svn_private_config.h"
 #include "svn_pools.h"
 #include "svn_error.h"
+#include "svn_ctype.h"
 #include "svn_dirent_uri.h"
 #include "svn_path.h"
 #include "svn_mergeinfo.h"
@@ -1806,11 +1807,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;
@@ -1822,9 +1823,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)
@@ -1832,7 +1837,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) */
@@ -1843,6 +1848,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);
@@ -1865,7 +1874,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;



Mime
View raw message