diff --git a/src/requests/auth.py b/src/requests/auth.py index c39b645189..54b3db3a37 100644 --- a/src/requests/auth.py +++ b/src/requests/auth.py @@ -183,6 +183,8 @@ def sha512_utf8(x): p_parsed = urlparse(url) #: path is request-uri defined in RFC 2616 which should not be empty path = p_parsed.path or "/" + if p_parsed.params: + path += f";{p_parsed.params}" if p_parsed.query: path += f"?{p_parsed.query}" diff --git a/tests/test_requests.py b/tests/test_requests.py index a482dd727d..67a068d649 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -807,6 +807,29 @@ def test_DIGESTAUTH_QUOTES_QOP_VALUE(self, httpbin): r = requests.get(url, auth=auth) assert '"auth"' in r.request.headers["Authorization"] + def test_DIGESTAUTH_PRESERVES_SEMICOLONS_IN_URI_PATH(self): + auth = HTTPDigestAuth("user", "pass") + auth.init_per_thread_state() + auth._thread_local.chal = { + "realm": "realm", + "nonce": "nonce", + "qop": "auth", + } + + header = auth.build_digest_header( + "PUT", + ( + "https://example.com/ws/2/collection/test/releases/" + "7dc2cfbd;38347564?fmt=json&client=manual-python-requests-test" + ), + ) + + assert ( + 'uri="/ws/2/collection/test/releases/' + '7dc2cfbd;38347564?fmt=json&client=manual-python-requests-test"' + in header + ) + def test_POSTBIN_GET_POST_FILES(self, httpbin): url = httpbin("post") requests.post(url).raise_for_status()