##// END OF EJS Templates
sshrepo: don't quote obviously safe strings (issue2983)...
Mads Kiilerich -
r15622:86fc364c default
parent child Browse files
Show More
@@ -5,6 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 import re
8 from i18n import _
9 from i18n import _
9 import util, error, wireproto
10 import util, error, wireproto
10
11
@@ -20,6 +21,8 b' class remotelock(object):'
20
21
21 def _serverquote(s):
22 def _serverquote(s):
22 '''quote a string for the remote shell ... which we assume is sh'''
23 '''quote a string for the remote shell ... which we assume is sh'''
24 if re.match(r'[a-zA-Z0-9._\-/]*$', s):
25 return s
23 return "'%s'" % s.replace("'", "'\\''")
26 return "'%s'" % s.replace("'", "'\\''")
24
27
25 class sshrepository(wireproto.wirerepository):
28 class sshrepository(wireproto.wirerepository):
@@ -105,13 +105,13 b' clone to existing repo'
105 output of dummyssh
105 output of dummyssh
106
106
107 $ cat dummylog
107 $ cat dummylog
108 Got arguments 1:user@dummy 2:'hg' init 'remote2'
108 Got arguments 1:user@dummy 2:hg init remote2
109 Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio
109 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio
110 Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio
110 Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio
111 Got arguments 1:user@dummy 2:'hg' init 'remote1'
111 Got arguments 1:user@dummy 2:hg init remote1
112 Got arguments 1:user@dummy 2:'hg' -R 'remote1' serve --stdio
112 Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio
113 Got arguments 1:user@dummy 2:'hg' init 'remote1'
113 Got arguments 1:user@dummy 2:hg init remote1
114 Got arguments 1:user@dummy 2:'hg' init 'remote1'
114 Got arguments 1:user@dummy 2:hg init remote1
115
115
116 comparing repositories
116 comparing repositories
117
117
@@ -275,27 +275,27 b' Test remote paths with spaces (issue2983'
275 3fb238f49e8c
275 3fb238f49e8c
276
276
277 $ cat dummylog
277 $ cat dummylog
278 Got arguments 1:user@dummy 2:'hg' -R 'nonexistent' serve --stdio
278 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio
279 Got arguments 1:user@dummy 2:'hg' -R '/$TESTTMP/nonexistent' serve --stdio
279 Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio
280 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
280 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
281 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
281 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
282 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
282 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
283 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
283 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
284 Got arguments 1:user@dummy 2:'hg' -R 'local' serve --stdio
284 Got arguments 1:user@dummy 2:hg -R local serve --stdio
285 Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/local' serve --stdio
285 Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio
286 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
286 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
287 changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
287 changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
288 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
288 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
289 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
289 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
290 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
290 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
291 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
291 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
292 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
292 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
293 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
293 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
294 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
294 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
295 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
295 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
296 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
296 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
297 changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
297 changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
298 Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio
298 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
299 Got arguments 1:user@dummy 2:'hg' init 'a repo'
299 Got arguments 1:user@dummy 2:hg init 'a repo'
300 Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio
300 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
301 Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio
301 Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio
@@ -98,8 +98,8 b' subrepo paths with ssh urls'
98 no changes found
98 no changes found
99
99
100 $ cat dummylog
100 $ cat dummylog
101 Got arguments 1:user@dummy 2:'hg' -R 'cloned' serve --stdio
101 Got arguments 1:user@dummy 2:hg -R cloned serve --stdio
102 Got arguments 1:user@dummy 2:'hg' -R 'sub' serve --stdio
102 Got arguments 1:user@dummy 2:hg -R sub serve --stdio
103 Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/cloned' serve --stdio
103 Got arguments 1:user@dummy 2:hg -R $TESTTMP/cloned serve --stdio
104 Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/sub' serve --stdio
104 Got arguments 1:user@dummy 2:hg -R $TESTTMP/sub serve --stdio
105 $ rm $BINDIR/ssh
105 $ rm $BINDIR/ssh
General Comments 0
You need to be logged in to leave comments. Login now