From 9ce69672f3a1fbd9f337737bf35ace1a1a592598 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Sat, 27 Sep 2014 16:56:15 -0400 Subject: #10510: make distuitls upload/register use HTML standards compliant CRLF. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Ian Cordasco, approved by Éric Araujo. --- Lib/distutils/command/upload.py | 10 +++++----- Lib/distutils/tests/test_upload.py | 2 +- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py index 180be7c..9b15b67 100644 --- a/Lib/distutils/command/upload.py +++ b/Lib/distutils/command/upload.py @@ -143,11 +143,11 @@ class upload(PyPIRCCommand): # Build up the MIME payload for the POST data boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' - sep_boundary = b'\n--' + boundary.encode('ascii') - end_boundary = sep_boundary + b'--' + sep_boundary = b'\r\n--' + boundary.encode('ascii') + end_boundary = sep_boundary + b'--\r\n' body = io.BytesIO() 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 if type(value) != type([]): value = [value] @@ -159,12 +159,12 @@ class upload(PyPIRCCommand): value = str(value).encode('utf-8') body.write(sep_boundary) body.write(title.encode('utf-8')) - body.write(b"\n\n") + body.write(b"\r\n\r\n") body.write(value) if value and value[-1:] == b'\r': body.write(b'\n') # write an extra newline (lurve Macs) body.write(end_boundary) - body.write(b"\n") + body.write(b"\r\n") body = body.getvalue() self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) diff --git a/Lib/distutils/tests/test_upload.py b/Lib/distutils/tests/test_upload.py index 0380f97..2401541 100644 --- a/Lib/distutils/tests/test_upload.py +++ b/Lib/distutils/tests/test_upload.py @@ -127,7 +127,7 @@ class uploadTestCase(PyPIRCCommandTestCase): # what did we send ? headers = dict(self.last_open.req.headers) - self.assertEqual(headers['Content-length'], '2087') + self.assertEqual(headers['Content-length'], '2163') content_type = headers['Content-type'] self.assertTrue(content_type.startswith('multipart/form-data')) self.assertEqual(self.last_open.req.get_method(), 'POST') diff --git a/Misc/ACKS b/Misc/ACKS index f077ff7..c13e4cd 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -279,6 +279,7 @@ Jason R. Coombs Garrett Cooper Greg Copeland Aldo Cortesi +Ian Cordasco David Costanzo Scott Cotton Greg Couch diff --git a/Misc/NEWS b/Misc/NEWS index 5647504..f95b593 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,9 @@ Core and Builtins 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 Oleg Oshmyan. -- cgit v0.12