We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70ced2d commit 741f22dCopy full SHA for 741f22d
3 files changed
Lib/test/test_urllib2.py
@@ -1846,9 +1846,17 @@ def test_parse_proxy(self):
1846
('ftp', 'joe', 'password', 'proxy.example.com')),
1847
# Test for no trailing '/' case
1848
('http://joe:password@proxy.example.com',
1849
- ('http', 'joe', 'password', 'proxy.example.com'))
+ ('http', 'joe', 'password', 'proxy.example.com')),
1850
+ # Testcases with '/' character in username, password
1851
+ ('http://user/name:password@localhost:22',
1852
+ ('http', 'user/name', 'password', 'localhost:22')),
1853
+ ('http://username:pass/word@localhost:22',
1854
+ ('http', 'username', 'pass/word', 'localhost:22')),
1855
+ ('http://user/name:pass/word@localhost:22',
1856
+ ('http', 'user/name', 'pass/word', 'localhost:22')),
1857
]
1858
1859
+
1860
for tc, expected in parse_proxy_test_cases:
1861
self.assertEqual(_parse_proxy(tc), expected)
1862
Lib/urllib/request.py
@@ -779,7 +779,11 @@ def _parse_proxy(proxy):
779
raise ValueError("proxy URL with no authority: %r" % proxy)
780
# We have an authority, so for RFC 3986-compliant URLs (by ss 3.
781
# and 3.3.), path is empty or starts with '/'
782
- end = r_scheme.find("/", 2)
+ if '@' in r_scheme:
783
+ host_separator = r_scheme.find('@')
784
+ end = r_scheme.find("/", host_separator)
785
+ else:
786
+ end = r_scheme.find("/", 2)
787
if end == -1:
788
end = None
789
authority = r_scheme[2:end]
Misc/NEWS.d/next/Library/2020-12-27-18-47-01.bpo-23328._xqepZ.rst
@@ -0,0 +1 @@
1
+Allow / character in username, password fields on _PROXY envars.
0 commit comments