File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 132
132
IPv4_RE ,
133
133
IP_LITERAL_RE ,
134
134
)
135
- USERINFO_RE = '^[A-Za-z0-9_.~\-%:]+'
135
+ USERINFO_RE = '^([' + UNRESERVED_RE + SUB_DELIMITERS_RE + ':]|%s)+' % (
136
+ PCT_ENCODED
137
+ )
136
138
PORT_RE = '[0-9]{1,5}'
137
139
138
140
# ####################
Original file line number Diff line number Diff line change @@ -58,6 +58,23 @@ def test_handles_uri_with_port_and_userinfo(
58
58
assert uri .fragment is None
59
59
assert uri .userinfo == 'user:pass'
60
60
61
+ def test_handles_tricky_userinfo (
62
+ self , uri_with_port_and_tricky_userinfo ):
63
+ """
64
+ Test that self.test_class can handle a URI with unusual
65
+ (non a-z) chars in userinfo.
66
+ """
67
+ uri = self .test_class .from_string (uri_with_port_and_tricky_userinfo )
68
+ assert uri .scheme == 'ssh'
69
+ # 6 == len('ftp://')
70
+ assert uri .authority == uri_with_port_and_tricky_userinfo [6 :]
71
+ assert uri .host != uri .authority
72
+ assert str (uri .port ) == '22'
73
+ assert uri .path is None
74
+ assert uri .query is None
75
+ assert uri .fragment is None
76
+ assert uri .userinfo == 'user%20!=:pass'
77
+
61
78
def test_handles_basic_uri_with_path (self , basic_uri_with_path ):
62
79
"""Test that self.test_class can handle a URI with a path."""
63
80
uri = self .test_class .from_string (basic_uri_with_path )
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ def uri_with_port_and_userinfo(request):
80
80
return 'ssh://user:pass@%s:22' % request .param
81
81
82
82
83
+ @pytest .fixture (params = valid_hosts )
84
+ def uri_with_port_and_tricky_userinfo (request ):
85
+ return 'ssh://%s@%s:22' % ('user%20!=:pass' , request .param )
86
+
87
+
83
88
@pytest .fixture (params = valid_hosts )
84
89
def basic_uri_with_path (request ):
85
90
return 'http://%s/path/to/resource' % request .param
You can’t perform that action at this time.
0 commit comments