Skip to content
Myr

Merge pull request from GHSA-j8r2-6x86-q33q

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by GitHub · parent 3022253 · Browse files · 2 files+23 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−1 removed

  • tests:+20 added−0 removed
  • other:+3 added−1 removed

2 files+23 added−1 removed

modified:requests/sessions.py+3 added-1 removed
322 unmodified lines
323 username, password = get_auth_from_url(new_proxies[scheme])324 except KeyError:325 username, password = None, None326327 if username and password:327 # urllib3 handles proxy authorization for us in the standard adapter.328 # Avoid appending this to TLS tunneled requests where it may be leaked.329 if not scheme.startswith('https') and username and password:330 headers["Proxy-Authorization"] = _basic_auth_str(username, password)331332 return new_proxies333
500 unmodified lines
modified:tests/test_requests.py+20 added
645 unmodified lines
646 sent_headers = resp.json().get("headers", {})647648 assert sent_headers.get("Proxy-Authorization") == proxy_auth_value649650651 @pytest.mark.parametrize(652 "url,has_proxy_auth",653 (654 ('http://example.com', True),655 ('https://example.com', False),656 ),657 )658 def test_proxy_authorization_not_appended_to_https_request(self, url, has_proxy_auth):659 session = requests.Session()660 proxies = {661 'http': 'http://test:pass@localhost:8080',662 'https': 'http://test:pass@localhost:8090',663 }664 req = requests.Request('GET', url)665 prep = req.prepare()666 session.rebuild_proxies(prep, proxies)667668 assert ('Proxy-Authorization' in prep.headers) is has_proxy_auth669670 def test_basicauth_with_netrc(self, httpbin):671 auth = ("user", "pass")672 wrong_auth = ("wronguser", "wrongpass")673 url = httpbin("basic-auth", "user", "pass")
2137 unmodified lines