Allow / character in username,password fields in _PROXY envvars. (GH-23973)
(cherry picked from commit 030a713183
)
Co-authored-by: Senthil Kumaran <senthil@uthcode.com>
This commit is contained in:
parent
1ceb097cec
commit
df794406a8
|
@ -1849,9 +1849,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)
|
||||||
|
|
||||||
|
|
|
@ -771,7 +771,11 @@ 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 '/'
|
||||||
end = r_scheme.find("/", 2)
|
if '@' in r_scheme:
|
||||||
|
host_separator = r_scheme.find('@')
|
||||||
|
end = r_scheme.find("/", host_separator)
|
||||||
|
else:
|
||||||
|
end = r_scheme.find("/", 2)
|
||||||
if end == -1:
|
if end == -1:
|
||||||
end = None
|
end = None
|
||||||
authority = r_scheme[2:end]
|
authority = r_scheme[2:end]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Allow / character in username, password fields on _PROXY envars.
|
Loading…
Reference in New Issue