瀏覽代碼

Fix minor location parser bug.

Make sure the entire input is parsed.
Jonas Borgström 11 年之前
父節點
當前提交
21e03af56b
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 3
      attic/helpers.py
  2. 1 0
      attic/testsuite/helpers.py

+ 3 - 3
attic/helpers.py

@@ -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

+ 1 - 0
attic/testsuite/helpers.py

@@ -49,6 +49,7 @@ class LocationTestCase(AtticTestCase):
             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):