mirror of https://github.com/python/cpython.git
Merge: #10510: make distuitls upload/register use HTML standards compliant CRLF.
This commit is contained in:
commit
3a54c3e3aa
|
@ -141,11 +141,11 @@ def upload_file(self, command, pyversion, filename):
|
||||||
|
|
||||||
# Build up the MIME payload for the POST data
|
# Build up the MIME payload for the POST data
|
||||||
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
||||||
sep_boundary = b'\n--' + boundary.encode('ascii')
|
sep_boundary = b'\r\n--' + boundary.encode('ascii')
|
||||||
end_boundary = sep_boundary + b'--'
|
end_boundary = sep_boundary + b'--\r\n'
|
||||||
body = io.BytesIO()
|
body = io.BytesIO()
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
title = '\nContent-Disposition: form-data; name="%s"' % key
|
title = '\r\nContent-Disposition: form-data; name="%s"' % key
|
||||||
# handle multiple entries for the same name
|
# handle multiple entries for the same name
|
||||||
if not isinstance(value, list):
|
if not isinstance(value, list):
|
||||||
value = [value]
|
value = [value]
|
||||||
|
@ -157,12 +157,12 @@ def upload_file(self, command, pyversion, filename):
|
||||||
value = str(value).encode('utf-8')
|
value = str(value).encode('utf-8')
|
||||||
body.write(sep_boundary)
|
body.write(sep_boundary)
|
||||||
body.write(title.encode('utf-8'))
|
body.write(title.encode('utf-8'))
|
||||||
body.write(b"\n\n")
|
body.write(b"\r\n\r\n")
|
||||||
body.write(value)
|
body.write(value)
|
||||||
if value and value[-1:] == b'\r':
|
if value and value[-1:] == b'\r':
|
||||||
body.write(b'\n') # write an extra newline (lurve Macs)
|
body.write(b'\n') # write an extra newline (lurve Macs)
|
||||||
body.write(end_boundary)
|
body.write(end_boundary)
|
||||||
body.write(b"\n")
|
body.write(b"\r\n")
|
||||||
body = body.getvalue()
|
body = body.getvalue()
|
||||||
|
|
||||||
msg = "Submitting %s to %s" % (filename, self.repository)
|
msg = "Submitting %s to %s" % (filename, self.repository)
|
||||||
|
|
|
@ -127,7 +127,7 @@ def test_upload(self):
|
||||||
|
|
||||||
# what did we send ?
|
# what did we send ?
|
||||||
headers = dict(self.last_open.req.headers)
|
headers = dict(self.last_open.req.headers)
|
||||||
self.assertEqual(headers['Content-length'], '2087')
|
self.assertEqual(headers['Content-length'], '2163')
|
||||||
content_type = headers['Content-type']
|
content_type = headers['Content-type']
|
||||||
self.assertTrue(content_type.startswith('multipart/form-data'))
|
self.assertTrue(content_type.startswith('multipart/form-data'))
|
||||||
self.assertEqual(self.last_open.req.get_method(), 'POST')
|
self.assertEqual(self.last_open.req.get_method(), 'POST')
|
||||||
|
|
|
@ -281,6 +281,7 @@ Jason R. Coombs
|
||||||
Garrett Cooper
|
Garrett Cooper
|
||||||
Greg Copeland
|
Greg Copeland
|
||||||
Aldo Cortesi
|
Aldo Cortesi
|
||||||
|
Ian Cordasco
|
||||||
David Costanzo
|
David Costanzo
|
||||||
Scott Cotton
|
Scott Cotton
|
||||||
Greg Couch
|
Greg Couch
|
||||||
|
|
|
@ -145,6 +145,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #10510: distutils register and upload methods now use HTML standards
|
||||||
|
compliant CRLF line endings.
|
||||||
|
|
||||||
- Issue #9850: Fixed macpath.join() for empty first component. Patch by
|
- Issue #9850: Fixed macpath.join() for empty first component. Patch by
|
||||||
Oleg Oshmyan.
|
Oleg Oshmyan.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue