You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Arkadiusz Miskiewicz <mi...@pld.ORG.PL> on 2002/04/14 09:27:48 UTC

cvs2svn.py patch

Hi,

cvs2svn.py doesn't work if there are filenames with special
shell meaning like ,,('' etc.

--- .SVN-OTHER/subversion/tools/cvs2svn/cvs2svn.py      Tue Apr  9 02:31:06 2002
+++ cvs2svn.py  Sun Apr 14 11:23:33 2002
@@ -359,7 +360,7 @@
         f = os.path.join(dirname, 'Attic', fname)
         statcache.stat(f)
 
-      pipe = os.popen('co -q -p%s %s' % (r, f), 'r', 102400)
+      pipe = os.popen('co -q -p%s \'%s\'' % (r, f), 'r', 102400)
 
       # if we just made the file, we can send it in one big hunk, rather
       # than streaming it in.
@@ -377,7 +378,7 @@
         # revision from co, or else the delta won't be correct because
         # the contents in the repo won't have changed yet.
         if repos_path == lastcommit[0]:
-          infile2 = os.popen("co -q -p%s %s" % (lastcommit[1], f), "r", 102400)
+          infile2 = os.popen("co -q -p%s \'%s\'" % (lastcommit[1], f), "r", 102400)
           stream1 = util.svn_stream_from_stdio(infile2, f_pool)
         else:
           stream1 = fs.file_contents(root, repos_path, f_pool)

Unfortunately cvs2svn.py still doesn't work:
...
committing: Sat May 12 16:16:56 2001, over 0 seconds
    changing 1.1 : /quota-tools/doc/edquota(8).html
    making dir: /quota-tools
    making dir: /quota-tools/doc
    changing 1.1 : /quota-tools/doc/fstab(5).html
    changing 1.1 : /quota-tools/doc/Makefile.am
    changing 1.1 : /quota-tools/doc/quota(1).html
    changing 1.1 : /quota-tools/doc/quota4th.fig
    changing 1.1 : /quota-tools/doc/quotacheck(8).html
    changing 1.1 : /quota-tools/doc/quotactl(2).html
    changing 1.1 : /quota-tools/doc/quota.html
    changing 1.1 : /quota-tools/doc/quotaon(8).html
    changing 1.1 : /quota-tools/doc/quotas-1.eps
    changing 1.1 : /quota-tools/doc/quotas.ms
    changing 1.1 : /quota-tools/doc/quotas.preformated
    changing 1.1 : /quota-tools/doc/repquota(8).html
    changing 1.1 : /quota-tools/doc/rquotad(8).html
    changing 1.1 : /quota-tools/doc/set_limits_example.c
    changing 1.1 : /quota-tools/doc/setup_quota_group
    changing 1.1 : /quota-tools/doc/warnquota.conf
Traceback (most recent call last):
  File "./cvs2svn.py", line 650, in ?
    main()
  File "./cvs2svn.py", line 647, in main
    start_pass=start_pass, verbose=verbose, target=target)
  File "/usr/lib/python2.2/site-packages/svn/util.py", line 33, in run_app
  File "./cvs2svn.py", line 612, in convert
    _passes[i](ctx)
  File "./cvs2svn.py", line 569, in pass4
    c.commit(t_fs, ctx)
  File "./cvs2svn.py", line 424, in commit
    conflicts, new_rev = fs.commit_txn(txn)
TypeError: unpack non-sequence

(no branches)
-- 
Arkadiusz Miśkiewicz   IPv6 ready PLD Linux at http://www.pld.org.pl
misiek(at)pld.org.pl   AM2-6BONE, 1024/3DB19BBD, arekm(at)ircnet, PWr


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Greg Stein <gs...@lyra.org>.
On Sun, Apr 14, 2002 at 11:39:16AM -0400, Greg Hudson wrote:
> On Sun, 2002-04-14 at 05:27, Arkadiusz Miskiewicz wrote:
> > -      pipe = os.popen('co -q -p%s %s' % (r, f), 'r', 102400)
> > +      pipe = os.popen('co -q -p%s \'%s\'' % (r, f), 'r', 102400)
> 
> This isn't a panacea; the filename could still contain single quotes.
> 
> It would be much more robust if you could construct the arguments as a
> list rather than relying on the shell.  Unfortunately, Python's "os"
> interface seems to be very much modeled on the Unix C library rather
> than what you'd get if you were designing an interface for Python; so,
> just as in C, you have to fork and exec yourself if you want to do
> things the robust way.

In the ViewCVS code, I have a popen module that uses fork/exec to protect
against shell syntax. It is definitely safer, which is a reqirement for a
program like ViewCVS :-)

Since the rcsparse module is already required from ViewCVS, it might make
some sense to also use popen. I'll take a look at it next time that I'm in
cvs2svn. (the swig bindings and cvs2svn definitely need to be reviewed to
check on their current state)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Patrik Husfloen <pa...@student.liu.se>.
I keep forgetting to cc the list:

Patrik Husfloen wrote:
>  > Or for a little less line-noise,
> 
>>     (r, string.replace(f, "'", "'\\''")),
> 
> 
> It's been a while, but wouldn't (r, f.replace("'", "'\\''")), work?
> even less "noise"
> 
> /patrik
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Zack Weinberg <za...@codesourcery.com>.
On Sun, Apr 14, 2002 at 07:11:30PM +0200, Marcus Comstedt wrote:
> 
> No need to escape all characters.  If the argument is enclosed in
> single quotes, then only single quotes need to be escaped.  Just do
> 
>       pipe = os.popen('co -q -p%s \'%s\'' %
>                           (r, string.replace(f, "'","'\"'\"'")),
>                       'r', 102400)

Or for a little less line-noise,

	(r, string.replace(f, "'", "'\\''")),

zw

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Marcus Comstedt <ma...@mc.pp.se>.
Arkadiusz Miskiewicz <mi...@pld.ORG.PL> writes:

> It's better than it was before. I've never seen a cvs file with single quotes
> in name but... ;) Anyway every character in file name could be escaped
> just to be sure but this isn't ,,beauty'' way.

No need to escape all characters.  If the argument is enclosed in
single quotes, then only single quotes need to be escaped.  Just do

      pipe = os.popen('co -q -p%s \'%s\'' %
                          (r, string.replace(f, "'","'\"'\"'")),
                      'r', 102400)

and it should be ok for all characters (although NUL characters could
still be a problem, but they are not valid in filenames anyway).


  // Marcus



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Arkadiusz Miskiewicz <mi...@pld.ORG.PL>.
Greg Hudson <gh...@MIT.EDU> writes:

> On Sun, 2002-04-14 at 05:27, Arkadiusz Miskiewicz wrote:
> > -      pipe = os.popen('co -q -p%s %s' % (r, f), 'r', 102400)
> > +      pipe = os.popen('co -q -p%s \'%s\'' % (r, f), 'r', 102400)
> 
> This isn't a panacea; the filename could still contain single quotes.
It's better than it was before. I've never seen a cvs file with single quotes
in name but... ;) Anyway every character in file name could be escaped
just to be sure but this isn't ,,beauty'' way.

-- 
Arkadiusz Miśkiewicz   IPv6 ready PLD Linux at http://www.pld.org.pl
misiek(at)pld.org.pl   AM2-6BONE, 1024/3DB19BBD, arekm(at)ircnet, PWr

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs2svn.py patch

Posted by Greg Hudson <gh...@MIT.EDU>.
On Sun, 2002-04-14 at 05:27, Arkadiusz Miskiewicz wrote:
> -      pipe = os.popen('co -q -p%s %s' % (r, f), 'r', 102400)
> +      pipe = os.popen('co -q -p%s \'%s\'' % (r, f), 'r', 102400)

This isn't a panacea; the filename could still contain single quotes.

It would be much more robust if you could construct the arguments as a
list rather than relying on the shell.  Unfortunately, Python's "os"
interface seems to be very much modeled on the Unix C library rather
than what you'd get if you were designing an interface for Python; so,
just as in C, you have to fork and exec yourself if you want to do
things the robust way.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: cvs2svn.py patch

Posted by Sander Striker <st...@apache.org>.
> From: misiek@arm.t19.ds.pwr.wroc.pl [mailto:misiek@arm.t19.ds.pwr.wroc.pl]On Behalf Of Arkadiusz Miskiewicz
> Sent: 14 April 2002 11:28

> Hi,
> 
> cvs2svn.py doesn't work if there are filenames with special
> shell meaning like ,,('' etc.
> 
> --- .SVN-OTHER/subversion/tools/cvs2svn/cvs2svn.py      Tue Apr  9 02:31:06 2002
> +++ cvs2svn.py  Sun Apr 14 11:23:33 2002
> @@ -359,7 +360,7 @@
>          f = os.path.join(dirname, 'Attic', fname)
>          statcache.stat(f)
>  
> -      pipe = os.popen('co -q -p%s %s' % (r, f), 'r', 102400)
> +      pipe = os.popen('co -q -p%s \'%s\'' % (r, f), 'r', 102400)
>  
>        # if we just made the file, we can send it in one big hunk, rather
>        # than streaming it in.
> @@ -377,7 +378,7 @@
>          # revision from co, or else the delta won't be correct because
>          # the contents in the repo won't have changed yet.
>          if repos_path == lastcommit[0]:
> -          infile2 = os.popen("co -q -p%s %s" % (lastcommit[1], f), "r", 102400)
> +          infile2 = os.popen("co -q -p%s \'%s\'" % (lastcommit[1], f), "r", 102400)
>            stream1 = util.svn_stream_from_stdio(infile2, f_pool)
>          else:
>            stream1 = fs.file_contents(root, repos_path, f_pool)
[...]

Committed, thanks.

Could you do me a favor?  Please read the HACKING file and submit
your next patch as described in there ;)

Thanks,

Sander

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org