[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Fix for issue 3609 - cat command

From: Noorul Islam K M <noorul_at_collab.net>
Date: Mon, 08 Nov 2010 11:40:13 +0530

Followup to r1030010

Log

[[[

Canonicalize paths before passing them to svn_client_cat2.

* subversion/svn/cat-cmd.c
  (svn_cl__cat): Canonicalize url or dirent before passing over to API.

* subversion/tests/cmdline/cat_tests.py
  (cat_url_special_characters, test_list): New test

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

]]]

Thanks and Regards
Noorul

Index: subversion/svn/cat-cmd.c
===================================================================
--- subversion/svn/cat-cmd.c (revision 1032461)
+++ subversion/svn/cat-cmd.c (working copy)
@@ -27,6 +27,7 @@
 
 /*** Includes. ***/
 
+#include "svn_path.h"
 #include "svn_pools.h"
 #include "svn_client.h"
 #include "svn_error.h"
@@ -71,6 +72,11 @@
       SVN_ERR(svn_opt_parse_path(&peg_revision, &truepath, target,
                                  subpool));
 
+ if (svn_path_is_url(truepath))
+ truepath = svn_uri_canonicalize(truepath, subpool);
+ else
+ truepath = svn_dirent_canonicalize(truepath, subpool);
+
       SVN_ERR(svn_cl__try(svn_client_cat2(out, truepath, &peg_revision,
                                           &(opt_state->start_revision),
                                           ctx, subpool),
Index: subversion/tests/cmdline/cat_tests.py
===================================================================
--- subversion/tests/cmdline/cat_tests.py (revision 1032461)
+++ subversion/tests/cmdline/cat_tests.py (working copy)
@@ -196,7 +196,21 @@
                                      ["This is the file 'iota'.\n", "$Revision: 2 $\n"],
                                      [], 'cat', iota_path)
 
+def cat_url_special_characters(sbox):
+ """special characters in svn cat URL"""
+ sbox.build(create_wc = False)
+ wc_dir = sbox.wc_dir
 
+ special_urls = [sbox.repo_url + '/A' + '/%2E',
+ sbox.repo_url + '%2F' + 'A']
+
+ expected_err = ["svn: warning: URL '" + sbox.repo_url + '/A' + "'"
+ + " refers to a directory\n"]
+
+ for url in special_urls:
+ svntest.actions.run_and_verify_svn2(None, None, expected_err, 0,
+ 'cat', url)
+
 ########################################################################
 # Run the tests
 
@@ -210,6 +224,7 @@
               cat_skip_uncattable,
               cat_unversioned_file,
               cat_keywords,
+ cat_url_special_characters,
              ]
 
 if __name__ == '__main__':
Received on 2010-11-08 07:11:55 CET

This is an archived mail posted to the Subversion Dev mailing list.