changeset 35005:88572b7e50fd stable

debugssl: convert port number to int (issue5757) It doesn't use util.getport(), which may resolve service name to port number.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 14 Dec 2017 22:07:46 +0900
parents 7b73bf1a48d4
children 0279c2267d00
files mercurial/debugcommands.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Tue Dec 12 18:22:11 2017 +0100
+++ b/mercurial/debugcommands.py	Thu Dec 14 22:07:46 2017 +0900
@@ -2086,10 +2086,12 @@
     url = util.url(source)
     addr = None
 
-    if url.scheme == 'https':
-        addr = (url.host, url.port or 443)
-    elif url.scheme == 'ssh':
-        addr = (url.host, url.port or 22)
+    defaultport = {'https': 443, 'ssh': 22}
+    if url.scheme in defaultport:
+        try:
+            addr = (url.host, int(url.port or defaultport[url.scheme]))
+        except ValueError:
+            raise error.Abort(_("malformed port number in URL"))
     else:
         raise error.Abort(_("only https and ssh connections are supported"))