[py-svn] r32954 - in py/dist/py/path/svn: . testing
guido at codespeak.net
guido at codespeak.net
Fri Oct 6 14:35:55 CEST 2006
Author: guido
Date: Fri Oct 6 14:35:53 2006
New Revision: 32954
Modified:
py/dist/py/path/svn/svncommon.py
py/dist/py/path/svn/testing/test_urlcommand.py
py/dist/py/path/svn/urlcommand.py
py/dist/py/path/svn/wccommand.py
Log:
Fixed support for @ and : in the host part of the URL, while disallowing it in
the path part.
Modified: py/dist/py/path/svn/svncommon.py
==============================================================================
--- py/dist/py/path/svn/svncommon.py (original)
+++ py/dist/py/path/svn/svncommon.py Fri Oct 6 14:35:53 2006
@@ -8,6 +8,7 @@
ALLOWED_CHARS = "_ -/\\=$.~" #add characters as necessary when tested
if sys.platform == "win32":
ALLOWED_CHARS += ":"
+ALLOWED_CHARS_HOST = ALLOWED_CHARS + '@:'
def _getsvnversion(ver=[]):
try:
@@ -25,12 +26,11 @@
text = str(text).replace('$', '\\$')
return text
-
-def _check_for_bad_chars(text):
+def _check_for_bad_chars(text, allowed_chars=ALLOWED_CHARS):
for c in str(text):
if c.isalnum():
continue
- if c in ALLOWED_CHARS:
+ if c in allowed_chars:
continue
return True
return False
Modified: py/dist/py/path/svn/testing/test_urlcommand.py
==============================================================================
--- py/dist/py/path/svn/testing/test_urlcommand.py (original)
+++ py/dist/py/path/svn/testing/test_urlcommand.py Fri Oct 6 14:35:53 2006
@@ -16,14 +16,12 @@
py.path.svnurl("svn+ssh://hello/world")
def test_svnurl_characters_at_user(self):
- py.test.skip('XXX fix me')
py.path.svnurl("http://user@host.com/some/dir")
def test_svnurl_characters_at_path(self):
py.test.raises(ValueError, 'py.path.svnurl("http://host.com/foo@bar")')
def test_svnurl_characters_colon_port(self):
- py.test.skip('XXX fix me')
py.path.svnurl("http://host.com:8080/some/dir")
def test_svnurl_characters_colon_path(self):
Modified: py/dist/py/path/svn/urlcommand.py
==============================================================================
--- py/dist/py/path/svn/urlcommand.py (original)
+++ py/dist/py/path/svn/urlcommand.py Fri Oct 6 14:35:53 2006
@@ -22,10 +22,12 @@
self = object.__new__(cls)
if not isinstance(path, str):
path = str(path)
- parts = path.split(":")
+ proto, uri = path.split("://", 1)
+ host, uripath = uri.split('/', 1)
# only check for bad chars in the non-protocol parts
- # XXX don't check svn+ssh host sections either
- if len(parts) > 2 or svncommon._check_for_bad_chars(''.join(parts[1:])):
+ if (svncommon._check_for_bad_chars(host, svncommon.ALLOWED_CHARS_HOST)
+ or svncommon._check_for_bad_chars(uripath,
+ svncommon.ALLOWED_CHARS)):
raise ValueError("bad char in path %s" % (path, ))
path = path.rstrip('/')
self.strpath = path
Modified: py/dist/py/path/svn/wccommand.py
==============================================================================
--- py/dist/py/path/svn/wccommand.py (original)
+++ py/dist/py/path/svn/wccommand.py Fri Oct 6 14:35:53 2006
@@ -23,11 +23,12 @@
def __new__(cls, wcpath=None):
self = object.__new__(cls)
- if isinstance(wcpath, cls):
- if wcpath.__class__ == cls:
- return wcpath
- wcpath = wcpath.localpath
- if svncommon._check_for_bad_chars(str(wcpath)):
+ if isinstance(wcpath, cls):
+ if wcpath.__class__ == cls:
+ return wcpath
+ wcpath = wcpath.localpath
+ if svncommon._check_for_bad_chars(str(wcpath),
+ svncommon.ALLOWED_CHARS):
raise ValueError("bad char in wcpath %s" % (wcpath, ))
self.localpath = py.path.local(wcpath)
return self
More information about the pytest-commit
mailing list