changeset 13900:a3403d5b0af3 stable

url: use a regex to hide unsupported ssh passwords (issue2754)
author Matt Mackall <mpm@selenic.com>
date Wed, 06 Apr 2011 15:10:47 -0500
parents 14c0988c314d
children d3890ead75be
files mercurial/url.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)