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 2010/11/03 19:34:29 UTC

svn commit: r1030598 - in /subversion/trunk/subversion: libsvn_client/revert.c svn/revert-cmd.c tests/cmdline/input_validation_tests.py

Author: stsp
Date: Wed Nov  3 18:34:28 2010
New Revision: 1030598

URL: http://svn.apache.org/viewvc?rev=1030598&view=rev
Log:
Make 'svn revert' verify that none of its targets are URLs.

* subversion/libsvn_client/revert.c,
  subversion/svn/revert-cmd.c
  (svn_client_revert2, svn_cl__revert): Raise an error if any targets
  look like URLs.

* subversion/tests/cmdline/input_validation_tests.py
  (invalid_revert_targets, test_list): New test.

Patch by: Noorul Islam K M <noorul{_AT_}collab.net>

Modified:
    subversion/trunk/subversion/libsvn_client/revert.c
    subversion/trunk/subversion/svn/revert-cmd.c
    subversion/trunk/subversion/tests/cmdline/input_validation_tests.py

Modified: subversion/trunk/subversion/libsvn_client/revert.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/revert.c?rev=1030598&r1=1030597&r2=1030598&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/revert.c (original)
+++ subversion/trunk/subversion/libsvn_client/revert.c Wed Nov  3 18:34:28 2010
@@ -27,6 +27,7 @@
 
 /*** Includes. ***/
 
+#include "svn_path.h"
 #include "svn_wc.h"
 #include "svn_client.h"
 #include "svn_dirent_uri.h"
@@ -37,6 +38,7 @@
 #include "client.h"
 #include "private/svn_wc_private.h"
 
+#include "svn_private_config.h"
 
 
 /*** Code. ***/
@@ -121,6 +123,19 @@ svn_client_revert2(const apr_array_heade
   svn_boolean_t use_commit_times;
   struct revert_with_write_lock_baton baton;
 
+  /* Don't even attempt to modify the working copy if any of the
+   * targets look like URLs. URLs are invalid input. */
+  for (i = 0; i < paths->nelts; i++)
+    {
+      const char *path = APR_ARRAY_IDX(paths, i, const char *);
+
+      if (svn_path_is_url(path))
+        return svn_error_return(svn_error_createf(SVN_ERR_ILLEGAL_TARGET,
+                                                  NULL,
+                                                  _("'%s' is not a local path"),
+                                                  path));
+    }
+  
   cfg = ctx->config ? apr_hash_get(ctx->config, SVN_CONFIG_CATEGORY_CONFIG,
                                    APR_HASH_KEY_STRING) : NULL;
 

Modified: subversion/trunk/subversion/svn/revert-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/revert-cmd.c?rev=1030598&r1=1030597&r2=1030598&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/revert-cmd.c (original)
+++ subversion/trunk/subversion/svn/revert-cmd.c Wed Nov  3 18:34:28 2010
@@ -27,6 +27,7 @@
 
 /*** Includes. ***/
 
+#include "svn_path.h"
 #include "svn_client.h"
 #include "svn_error_codes.h"
 #include "svn_error.h"
@@ -47,6 +48,7 @@ svn_cl__revert(apr_getopt_t *os,
   svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
   apr_array_header_t *targets = NULL;
   svn_error_t *err;
+  int i;
 
   SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
                                                       opt_state->targets,
@@ -63,9 +65,21 @@ svn_cl__revert(apr_getopt_t *os,
 
   SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, scratch_pool));
 
+  /* Don't even attempt to modify the working copy if any of the
+   * targets look like URLs. URLs are invalid input. */
+  for (i = 0; i < targets->nelts; i++)
+    {
+      const char *target = APR_ARRAY_IDX(targets, i, const char *);
+
+      if (svn_path_is_url(target))
+        return svn_error_return(svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR,
+                                                  NULL,
+                                                  _("'%s' is not a local path"),
+                                                  target));
+    }
+
   err = svn_client_revert2(targets, opt_state->depth,
                            opt_state->changelists, ctx, scratch_pool);
-
   if (err
       && (err->apr_err == SVN_ERR_WC_INVALID_OPERATION_DEPTH)
       && (! SVN_DEPTH_IS_RECURSIVE(opt_state->depth)))

Modified: subversion/trunk/subversion/tests/cmdline/input_validation_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/input_validation_tests.py?rev=1030598&r1=1030597&r2=1030598&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/input_validation_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/input_validation_tests.py Wed Nov  3 18:34:28 2010
@@ -187,6 +187,13 @@ def invalid_resolved_targets(sbox):
     run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'resolved',
                              target)
 
+def invalid_revert_targets(sbox):
+  "non-working copy paths for 'revert'"
+  sbox.build(read_only=True)
+  for target in _invalid_wc_path_targets:
+    run_and_verify_svn_in_wc(sbox, "svn:.*is not a local path", 'revert',
+                             target)
+
 ########################################################################
 # Run the tests
 
@@ -207,6 +214,7 @@ test_list = [ None,
               invalid_wcpath_upgrade,
               invalid_resolve_targets,
               invalid_resolved_targets,
+              invalid_revert_targets,
              ]
 
 if __name__ == '__main__':