]> granicus.if.org Git - python/commitdiff
#10510: make distuitls upload/register use HTML standards compliant CRLF.
authorR David Murray <rdmurray@bitdance.com>
Sat, 27 Sep 2014 20:56:15 +0000 (16:56 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 27 Sep 2014 20:56:15 +0000 (16:56 -0400)
Patch by Ian Cordasco, approved by Éric Araujo.

Lib/distutils/command/upload.py
Lib/distutils/tests/test_upload.py
Misc/ACKS
Misc/NEWS

index 180be7c750949f64c1efcf20b08b3eacfe4e3344..9b15b67bae183f7244007542485532a030dcaedc 100644 (file)
@@ -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)
index 0380f97944fcbdbf07cc53aa3dffba7dc4e548d9..24015416eb6bc385bad804e24d6c6190b8d317a9 100644 (file)
@@ -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')
index f077ff77cdc84fbd337a606ece09c177bc9fda0f..c13e4cd3ac9c6acdf1d087273d17a969a605c4ae 100644 (file)
--- 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
index 564750451b6e96567df7a5df5e43c5db196f2c42..f95b593640c528f37a6d6a21d5f011fe1eb5acca 100644 (file)
--- 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.