diff --git a/ZConfig/loader.py b/ZConfig/loader.py index 2873317..27ca7df 100644 --- a/ZConfig/loader.py +++ b/ZConfig/loader.py @@ -28,6 +28,8 @@ import ZConfig.schema import ZConfig.url +_schemesep = None + def loadSchema(url): return SchemaLoader().loadURL(url) @@ -131,11 +133,13 @@ class BaseLoader: def isPath(self, s): """Return True iff 's' should be handled as a filesystem path.""" if ":" in s: - # XXX This assumes that one-character scheme identifiers - # are always Windows drive letters; I don't know of any - # one-character scheme identifiers. - scheme, rest = urllib.splittype(s) - return len(scheme) == 1 + # XXX This assumes that scheme are always separated by "://" + # and that they do not contains any ':' or '/' + global _schemesep + if _schemesep is None: + import re + _schemesep = re.compile('^([^/:]+)://') + return _schemesep.match(s) is None else: return True diff --git a/ZConfig/tests/test_loader.py b/ZConfig/tests/test_loader.py index 0b7598d..6691b82 100644 --- a/ZConfig/tests/test_loader.py +++ b/ZConfig/tests/test_loader.py @@ -234,6 +234,9 @@ class LoaderTestCase(TestBase): assert_(not isPath("http://www.example.com/sample.conf")) assert_(not isPath("file:///etc/zope/zope.conf")) assert_(not isPath("file:///c|/foo/bar.conf")) + # protect directories containing ":" + assert_(isPath("/ab:c")) + assert_(isPath("ab:c")) class TestNonExistentResources(unittest.TestCase):