From 21e03af56be1308bc7c685628b9827810a0b9279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Fri, 8 Aug 2014 23:34:27 +0200 Subject: [PATCH] Fix minor location parser bug. Make sure the entire input is parsed. --- attic/helpers.py | 6 +++--- attic/testsuite/helpers.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/attic/helpers.py b/attic/helpers.py index d749dbd2a..2ad280635 100644 --- a/attic/helpers.py +++ b/attic/helpers.py @@ -412,11 +412,11 @@ class Location: proto = user = host = port = path = archive = None ssh_re = re.compile(r'(?Pssh)://(?:(?P[^@]+)@)?' r'(?P[^:/#]+)(?::(?P\d+))?' - r'(?P[^:]+)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?$') file_re = re.compile(r'(?Pfile)://' - r'(?P[^:]+)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?$') scp_re = re.compile(r'((?:(?P[^@]+)@)?(?P[^:/]+):)?' - r'(?P[^:]+)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?$') def __init__(self, text): self.orig = text diff --git a/attic/testsuite/helpers.py b/attic/testsuite/helpers.py index 5b1d44dc5..e01b652c0 100644 --- a/attic/testsuite/helpers.py +++ b/attic/testsuite/helpers.py @@ -49,6 +49,7 @@ class LocationTestCase(AtticTestCase): repr(Location('some/relative/path::archive')), "Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='archive')" ) + self.assert_raises(ValueError, lambda: Location('ssh://localhost:22/path:archive')) class FormatTimedeltaTestCase(AtticTestCase):