Merge pull request #26 from KostyaEsmukov/userinfo_allowed_chars
Fix some chars (!, =, etc) being treated as not allowed in userinfo of authority
This commit is contained in:
commit
4d7a32699a
|
@ -132,7 +132,9 @@ HOST_RE = HOST_PATTERN = '({0}|{1}|{2})'.format(
|
|||
IPv4_RE,
|
||||
IP_LITERAL_RE,
|
||||
)
|
||||
USERINFO_RE = '^[A-Za-z0-9_.~\-%:]+'
|
||||
USERINFO_RE = '^([' + UNRESERVED_RE + SUB_DELIMITERS_RE + ':]|%s)+' % (
|
||||
PCT_ENCODED
|
||||
)
|
||||
PORT_RE = '[0-9]{1,5}'
|
||||
|
||||
# ####################
|
||||
|
|
|
@ -58,6 +58,23 @@ class BaseTestParsesURIs:
|
|||
assert uri.fragment is None
|
||||
assert uri.userinfo == 'user:pass'
|
||||
|
||||
def test_handles_tricky_userinfo(
|
||||
self, uri_with_port_and_tricky_userinfo):
|
||||
"""
|
||||
Test that self.test_class can handle a URI with unusual
|
||||
(non a-z) chars in userinfo.
|
||||
"""
|
||||
uri = self.test_class.from_string(uri_with_port_and_tricky_userinfo)
|
||||
assert uri.scheme == 'ssh'
|
||||
# 6 == len('ftp://')
|
||||
assert uri.authority == uri_with_port_and_tricky_userinfo[6:]
|
||||
assert uri.host != uri.authority
|
||||
assert str(uri.port) == '22'
|
||||
assert uri.path is None
|
||||
assert uri.query is None
|
||||
assert uri.fragment is None
|
||||
assert uri.userinfo == 'user%20!=:pass'
|
||||
|
||||
def test_handles_basic_uri_with_path(self, basic_uri_with_path):
|
||||
"""Test that self.test_class can handle a URI with a path."""
|
||||
uri = self.test_class.from_string(basic_uri_with_path)
|
||||
|
|
|
@ -80,6 +80,11 @@ def uri_with_port_and_userinfo(request):
|
|||
return 'ssh://user:pass@%s:22' % request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=valid_hosts)
|
||||
def uri_with_port_and_tricky_userinfo(request):
|
||||
return 'ssh://%s@%s:22' % ('user%20!=:pass', request.param)
|
||||
|
||||
|
||||
@pytest.fixture(params=valid_hosts)
|
||||
def basic_uri_with_path(request):
|
||||
return 'http://%s/path/to/resource' % request.param
|
||||
|
|
Loading…
Reference in New Issue