Allow / character in username,password fields in _PROXY envvars. (#23973)
This commit is contained in:
parent
c1af128f5a
commit
030a713183
|
@ -1851,9 +1851,17 @@ class MiscTests(unittest.TestCase):
|
||||||
('ftp', 'joe', 'password', 'proxy.example.com')),
|
('ftp', 'joe', 'password', 'proxy.example.com')),
|
||||||
# Test for no trailing '/' case
|
# Test for no trailing '/' case
|
||||||
('http://joe:password@proxy.example.com',
|
('http://joe:password@proxy.example.com',
|
||||||
('http', 'joe', 'password', 'proxy.example.com'))
|
('http', 'joe', 'password', 'proxy.example.com')),
|
||||||
|
# Testcases with '/' character in username, password
|
||||||
|
('http://user/name:password@localhost:22',
|
||||||
|
('http', 'user/name', 'password', 'localhost:22')),
|
||||||
|
('http://username:pass/word@localhost:22',
|
||||||
|
('http', 'username', 'pass/word', 'localhost:22')),
|
||||||
|
('http://user/name:pass/word@localhost:22',
|
||||||
|
('http', 'user/name', 'pass/word', 'localhost:22')),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
for tc, expected in parse_proxy_test_cases:
|
for tc, expected in parse_proxy_test_cases:
|
||||||
self.assertEqual(_parse_proxy(tc), expected)
|
self.assertEqual(_parse_proxy(tc), expected)
|
||||||
|
|
||||||
|
|
|
@ -773,6 +773,10 @@ def _parse_proxy(proxy):
|
||||||
raise ValueError("proxy URL with no authority: %r" % proxy)
|
raise ValueError("proxy URL with no authority: %r" % proxy)
|
||||||
# We have an authority, so for RFC 3986-compliant URLs (by ss 3.
|
# We have an authority, so for RFC 3986-compliant URLs (by ss 3.
|
||||||
# and 3.3.), path is empty or starts with '/'
|
# and 3.3.), path is empty or starts with '/'
|
||||||
|
if '@' in r_scheme:
|
||||||
|
host_separator = r_scheme.find('@')
|
||||||
|
end = r_scheme.find("/", host_separator)
|
||||||
|
else:
|
||||||
end = r_scheme.find("/", 2)
|
end = r_scheme.find("/", 2)
|
||||||
if end == -1:
|
if end == -1:
|
||||||
end = None
|
end = None
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Allow / character in username, password fields on _PROXY envars.
|
Loading…
Reference in New Issue