mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
5f38b8407b
commit
c4e671eec2
4 changed files with 71 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue