1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

Fix minor location parser bug.

Make sure the entire input is parsed.
This commit is contained in:
Jonas Borgström 2014-08-08 23:34:27 +02:00
parent 9f64e39d9f
commit 21e03af56b
2 changed files with 4 additions and 3 deletions

View file

@ -412,11 +412,11 @@ class Location:
proto = user = host = port = path = archive = None proto = user = host = port = path = archive = None
ssh_re = re.compile(r'(?P<proto>ssh)://(?:(?P<user>[^@]+)@)?' ssh_re = re.compile(r'(?P<proto>ssh)://(?:(?P<user>[^@]+)@)?'
r'(?P<host>[^:/#]+)(?::(?P<port>\d+))?' r'(?P<host>[^:/#]+)(?::(?P<port>\d+))?'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?') r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
file_re = re.compile(r'(?P<proto>file)://' file_re = re.compile(r'(?P<proto>file)://'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?') r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
scp_re = re.compile(r'((?:(?P<user>[^@]+)@)?(?P<host>[^:/]+):)?' scp_re = re.compile(r'((?:(?P<user>[^@]+)@)?(?P<host>[^:/]+):)?'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?') r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
def __init__(self, text): def __init__(self, text):
self.orig = text self.orig = text

View file

@ -49,6 +49,7 @@ def test(self):
repr(Location('some/relative/path::archive')), repr(Location('some/relative/path::archive')),
"Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='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): class FormatTimedeltaTestCase(AtticTestCase):