Fix extract_host_port port separation

Regex quantifier should be lazy to make port separation work.
master
cbachert 4 years ago
parent 966383c762
commit 72a9ec5b7c

@ -84,7 +84,7 @@ def get_status(protocol, status):
return status, codes[protocol] return status, codes[protocol]
def extract_host_port(host_and_port, default_port): def extract_host_port(host_and_port, default_port):
host, _, port = re.match('^(.*)(:([0-9]*))?$', host_and_port).groups() host, _, port = re.match('^(.*?)(:([0-9]*))?$', host_and_port).groups()
return host, int(port) if port else default_port return host, int(port) if port else default_port
def get_server(protocol, authenticated=False): def get_server(protocol, authenticated=False):

@ -28,7 +28,7 @@ poll "{host}" proto {protocol} port {port}
def extract_host_port(host_and_port, default_port): def extract_host_port(host_and_port, default_port):
host, _, port = re.match('^(.*)(:([0-9]*))?$', host_and_port).groups() host, _, port = re.match('^(.*?)(:([0-9]*))?$', host_and_port).groups()
return host, int(port) if port else default_port return host, int(port) if port else default_port

Loading…
Cancel
Save