changeset 23671:e3f30068d2eb stable

sshpeer: more thorough shell quoting This fixes an issue spotted by Jesse Hertz.
author Matt Mackall <mpm@selenic.com>
date Mon, 29 Dec 2014 14:27:02 -0600
parents b65a01a4316b
children 14ac0c1579cd 97eb62b0f4a9
files mercurial/sshpeer.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Mon Dec 29 15:59:56 2014 +0900
+++ b/mercurial/sshpeer.py	Mon Dec 29 14:27:02 2014 -0600
@@ -20,6 +20,8 @@
             self.release()
 
 def _serverquote(s):
+    if not s:
+        return s
     '''quote a string for the remote shell ... which we assume is sh'''
     if re.match('[a-zA-Z0-9@%_+=:,./-]*$', s):
         return s
@@ -45,7 +47,10 @@
         sshcmd = self.ui.config("ui", "ssh", "ssh")
         remotecmd = self.ui.config("ui", "remotecmd", "hg")
 
-        args = util.sshargs(sshcmd, self.host, self.user, self.port)
+        args = util.sshargs(sshcmd,
+                            _serverquote(self.host),
+                            _serverquote(self.user),
+                            _serverquote(self.port))
 
         if create:
             cmd = '%s %s %s' % (sshcmd, args,