diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py --- a/mercurial/sshrepo.py +++ b/mercurial/sshrepo.py @@ -5,6 +5,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +import re from i18n import _ import util, error, wireproto @@ -20,6 +21,8 @@ class remotelock(object): def _serverquote(s): '''quote a string for the remote shell ... which we assume is sh''' + if re.match(r'[a-zA-Z0-9._\-/]*$', s): + return s return "'%s'" % s.replace("'", "'\\''") class sshrepository(wireproto.wirerepository): diff --git a/tests/test-init.t b/tests/test-init.t --- a/tests/test-init.t +++ b/tests/test-init.t @@ -105,13 +105,13 @@ clone to existing repo output of dummyssh $ cat dummylog - Got arguments 1:user@dummy 2:'hg' init 'remote2' - Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'remote1' - Got arguments 1:user@dummy 2:'hg' -R 'remote1' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'remote1' - Got arguments 1:user@dummy 2:'hg' init 'remote1' + Got arguments 1:user@dummy 2:hg init remote2 + Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio + Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio + Got arguments 1:user@dummy 2:hg init remote1 + Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio + Got arguments 1:user@dummy 2:hg init remote1 + Got arguments 1:user@dummy 2:hg init remote1 comparing repositories diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -275,27 +275,27 @@ Test remote paths with spaces (issue2983 3fb238f49e8c $ cat dummylog - Got arguments 1:user@dummy 2:'hg' -R 'nonexistent' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '/$TESTTMP/nonexistent' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'local' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/local' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio + Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio + Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R local serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'a repo' - Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg init 'a repo' + Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio + Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio diff --git a/tests/test-subrepo-relative-path.t b/tests/test-subrepo-relative-path.t --- a/tests/test-subrepo-relative-path.t +++ b/tests/test-subrepo-relative-path.t @@ -98,8 +98,8 @@ subrepo paths with ssh urls no changes found $ cat dummylog - Got arguments 1:user@dummy 2:'hg' -R 'cloned' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'sub' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/cloned' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/sub' serve --stdio + Got arguments 1:user@dummy 2:hg -R cloned serve --stdio + Got arguments 1:user@dummy 2:hg -R sub serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/cloned serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/sub serve --stdio $ rm $BINDIR/ssh