diff options
-rw-r--r-- | ssh.py | 2 | ||||
-rw-r--r-- | tests/test_ssh.py | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -42,7 +42,7 @@ def _parse_ssh_version(ver_str=None): | |||
42 | """parse a ssh version string into a tuple""" | 42 | """parse a ssh version string into a tuple""" |
43 | if ver_str is None: | 43 | if ver_str is None: |
44 | ver_str = _run_ssh_version() | 44 | ver_str = _run_ssh_version() |
45 | m = re.match(r"^OpenSSH_([0-9.]+)(p[0-9]+)?\s", ver_str) | 45 | m = re.match(r"^OpenSSH_([0-9.]+)(p[0-9]+)?[\s,]", ver_str) |
46 | if m: | 46 | if m: |
47 | return tuple(int(x) for x in m.group(1).split(".")) | 47 | return tuple(int(x) for x in m.group(1).split(".")) |
48 | else: | 48 | else: |
diff --git a/tests/test_ssh.py b/tests/test_ssh.py index a9c1be7f..d74f7fe8 100644 --- a/tests/test_ssh.py +++ b/tests/test_ssh.py | |||
@@ -39,6 +39,8 @@ class SshTests(unittest.TestCase): | |||
39 | "OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n" | 39 | "OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n" |
40 | ) | 40 | ) |
41 | self.assertEqual(ver, (7, 6)) | 41 | self.assertEqual(ver, (7, 6)) |
42 | ver = ssh._parse_ssh_version("OpenSSH_9.0p1, LibreSSL 3.3.6\n") | ||
43 | self.assertEqual(ver, (9, 0)) | ||
42 | 44 | ||
43 | def test_version(self): | 45 | def test_version(self): |
44 | """Check version() handling.""" | 46 | """Check version() handling.""" |