From bfe6a35a69a2bc0b61348116a734dba53002d4b4 Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Wed, 6 Apr 2011 15:10:47 -0500 Subject: [PATCH] url: use a regex to hide unsupported ssh passwords (issue2754) --- mercurial/url.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mercurial/url.py b/mercurial/url.py index 82ddccbfa0..8c4dbdd6f2 100644 --- a/mercurial/url.py +++ b/mercurial/url.py @@ -25,6 +25,9 @@ def _urlunparse(scheme, netloc, path, params, query, fragment, url): 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)