diff options
author | Gregory P. Smith <greg@krypto.org> | 2019-04-30 19:12:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 19:12:21 -0700 |
commit | c4e671eec20dfcb29b18596a89ef075f826c9f96 (patch) | |
tree | ed97dd046a1467e029caed8416ed6de7182ef53a /Lib/test/test_xmlrpc.py | |
parent | 5f38b8407b071acd96da2c8cde411d0e26967735 (diff) | |
download | cpython-git-c4e671eec20dfcb29b18596a89ef075f826c9f96.tar.gz |
bpo-30458: Disallow control chars in http URLs. (GH-12755)
Disallow control chars in http URLs in urllib.urlopen. This addresses a potential security problem for applications that do not sanity check their URLs where http request headers could be injected.
Diffstat (limited to 'Lib/test/test_xmlrpc.py')
-rw-r--r-- | Lib/test/test_xmlrpc.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 9c8b6958c6..52bacc1eaf 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -943,8 +943,13 @@ class SimpleServerTestCase(BaseServerTestCase): def test_partial_post(self): # Check that a partial POST doesn't make the server loop: issue #14001. - with contextlib.closing(http.client.HTTPConnection(ADDR, PORT)) as conn: - conn.request('POST', '/RPC2 HTTP/1.0\r\nContent-Length: 100\r\n\r\nbye') + with contextlib.closing(socket.create_connection((ADDR, PORT))) as conn: + conn.send('POST /RPC2 HTTP/1.0\r\n' + 'Content-Length: 100\r\n\r\n' + 'bye HTTP/1.1\r\n' + f'Host: {ADDR}:{PORT}\r\n' + 'Accept-Encoding: identity\r\n' + 'Content-Length: 0\r\n\r\n'.encode('ascii')) def test_context_manager(self): with xmlrpclib.ServerProxy(URL) as server: |