[PATCH] sshrepo: catch passwords in ssh urls

Adrian Buehlmann adrian at cadifra.com
Wed Feb 23 07:21:33 CST 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1298457761 -3600
# Branch stable
# Node ID da0ddd62b9d84fa40fe53e19708e92855a6cc800
# Parent  22f948c027a97e640ae74021dfdfd8014717705d
sshrepo: catch passwords in ssh urls

see also e4b02eb825b1

diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py
--- a/mercurial/sshrepo.py
+++ b/mercurial/sshrepo.py
@@ -29,6 +29,8 @@ class sshrepository(wireproto.wirereposi
             self._abort(error.RepoError(_("couldn't parse location %s") % path))
 
         self.user = m.group(2)
+        if self.user and ':' in self.user:
+            self._abort(error.RepoError(_("password in URL not supported")))
         self.host = m.group(3)
         self.port = m.group(5)
         self.path = m.group(7) or "."
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -269,6 +269,13 @@ push should succeed even though it has a
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     z
   
+
+passwords in ssh urls are not supported
+
+  $ hg push ssh://user:erroneouspwd@dummy/remote
+  abort: password in URL not supported!
+  [255]
+
   $ cd ..
   $ cat dummylog
   Got arguments 1:user at dummy 2:hg -R nonexistent serve --stdio


More information about the Mercurial-devel mailing list