url: use a regex to hide unsupported ssh passwords (issue2754) stable
authorMatt Mackall <mpm@selenic.com>
Wed, 06 Apr 2011 15:10:47 -0500
branchstable
changeset 13900 a3403d5b0af3
parent 13894 14c0988c314d
child 13901 d3890ead75be
url: use a regex to hide unsupported ssh passwords (issue2754)
mercurial/url.py
--- a/mercurial/url.py	Sun Mar 27 13:34:20 2011 +0200
+++ b/mercurial/url.py	Wed Apr 06 15:10:47 2011 -0500
@@ -25,6 +25,9 @@
 
 def hidepassword(url):
     '''hide user credential in a url string'''
+    if url.startswith("ssh://"):
+        # urllib doesn't know about ssh urls
+        return re.sub(r'(ssh://[^/]+):[^/]+(@.*)', r'\1:***\2', url)
     scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
     netloc = re.sub('([^:]*):([^@]*)@(.*)', r'\1:***@\3', netloc)
     return _urlunparse(scheme, netloc, path, params, query, fragment, url)